-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cc9e2b9
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ubuntu:latest at 2019-02-12T19:22:56IST | ||
FROM ubuntu@sha256:7a47ccc3bbe8a451b500d2b53104868b46d60ee8f5b35a24b41a86077c650210 | ||
|
||
LABEL "com.github.actions.icon"="code" | ||
LABEL "com.github.actions.color"="purple" | ||
LABEL "com.github.actions.name"="PHPCS Inspection" | ||
LABEL "com.github.actions.description"="This will run phpcs on PRs" | ||
|
||
RUN echo "tzdata tzdata/Areas select Asia" | debconf-set-selections && \ | ||
echo "tzdata tzdata/Zones/Asia select Kolkata" | debconf-set-selections | ||
|
||
RUN set -eux; \ | ||
apt-get update; \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
git \ | ||
gosu \ | ||
php7.2-cli \ | ||
php7.2-curl \ | ||
php-xml \ | ||
python \ | ||
python-pip \ | ||
rsync \ | ||
sudo \ | ||
tree \ | ||
vim \ | ||
wget ; \ | ||
pip install shyaml; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
# verify that the binary works | ||
gosu nobody true | ||
|
||
RUN useradd -m -s /bin/bash rtbot | ||
|
||
RUN wget https://raw.githubusercontent.com/Automattic/vip-go-ci/master/tools-init.sh -O tools-init.sh && \ | ||
bash tools-init.sh && \ | ||
rm -f tools-init.sh | ||
|
||
COPY entrypoint.sh main.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/*.sh | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 rtCamp | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# PHPCS Inspections - GitHub Action | ||
|
||
A [GitHub Action](https://github.com/features/actions) for running code inspections. It is based on https://github.com/Automattic/vip-go-ci/ | ||
|
||
You can use this action to work on latest commits pushed to Pull-Requests on GitHub, looking for problems in the code using PHP lint and PHPCS, and posting back to GitHub comments and reviews, detailing the issues found. | ||
|
||
* This action by default respects standards specified in [phpcs.xml](https://github.com/rtCamp/github-actions-wordpress-skeleton/blob/master/phpcs.xml) file. | ||
|
||
* If no `phpcs.xml` file is found in the root of the repository then by default inspection is carried out using: `WordPress-Core and WordPress-Docs` standards. | ||
|
||
This action is a part of [GitHub action library](https://github.com/rtCamp/github-actions-library/) created by [rtCamp](https://github.com/rtCamp/). | ||
|
||
## Installation | ||
|
||
> Note: To use this GitHub Action, you must have access to GitHub Actions. GitHub Actions are currently only available in public beta (you must [apply for access](https://github.com/features/actions)). | ||
Here is an example setup of this action: | ||
|
||
1. Create a `.github/main.workflow` in your GitHub repo. | ||
2. Add the following code to the `main.workflow` file and commit it to the repo's `master` branch. | ||
3. Define `USER_GITHUB_TOKEN` as a [GitHub Actions Secret](https://developer.github.com/actions/creating-workflows/storing-secrets). (You can add secrets using the visual workflow editor or the repository settings.) | ||
[Read here](#environment-variables) for more info on how to setup this variable. | ||
|
||
```bash | ||
workflow "Run Inspections" { | ||
resolves = ["PHPCS Inspections"] | ||
on = "pull_request" | ||
} | ||
|
||
action "PHPCS Inspections" { | ||
uses = "rtCamp/action-vip-go-ci@master" | ||
secrets = ["USER_GITHUB_TOKEN"] | ||
} | ||
``` | ||
|
||
4. Whenever you create a pull request or commit on an existing pull request, this action will run. | ||
|
||
## Environment Variables | ||
|
||
`USER_GITHUB_TOKEN`: [GitHub token](https://github.com/settings/tokens), that will be used to post review comments on opened pull requests if any issue is found during the inspections run. | ||
|
||
1. It is recommended to create this token from a bot user account. | ||
2. Permissions required for this token differ according to which type of repo this workflow has been setup for. | ||
1. Private Repo: Complete `repo` as well as `write:discussion` permission. | ||
2. Public Repo: Only `public_repo` permission. | ||
|
||
## License | ||
|
||
[MIT](LICENSE) © 2019 rtCamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
# custom path for files to override default files | ||
custom_path="$GITHUB_WORKSPACE/.github/inspections/vip-go-ci/" | ||
main_script="/usr/local/bin/main.sh" | ||
|
||
if [[ -d "$custom_path" ]]; then | ||
rsync -a "$custom_path" /usr/local/bin/ | ||
fi | ||
|
||
bash "$main_script" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
stars=$(printf "%-30s" "*") | ||
|
||
export CI_SCRIPT_OPTIONS="ci_script_options" | ||
export RTBOT_WORKSPACE="/home/rtbot/github-workspace" | ||
hosts_file="$GITHUB_WORKSPACE/.github/hosts.yml" | ||
|
||
rsync -a "$GITHUB_WORKSPACE/" "$RTBOT_WORKSPACE" | ||
rsync -a /root/vip-go-ci-tools/ /home/rtbot/vip-go-ci-tools | ||
chown -R rtbot:rtbot /home/rtbot/ | ||
|
||
GITHUB_REPO_NAME=${GITHUB_REPOSITORY##*/} | ||
GITHUB_REPO_OWNER=${GITHUB_REPOSITORY%%/*} | ||
|
||
phpcs_standard='' | ||
VIP="false" | ||
if [[ -f "$hosts_file" ]]; then | ||
VIP=$(cat "$hosts_file" | shyaml get-value "$CI_SCRIPT_OPTIONS.vip" | tr '[:upper:]' '[:lower:]') | ||
fi | ||
|
||
if [[ -f "$RTBOT_WORKSPACE/phpcs.xml" ]]; then | ||
phpcs_standard="--phpcs-standard=$RTBOT_WORKSPACE/phpcs.xml" | ||
elif [[ "$VIP" = "true" ]]; then | ||
phpcs_standard="--phpcs-standard=WordPress-VIP-Go --phpcs-severity=1" | ||
else | ||
phpcs_standard="--phpcs-standard=WordPress-Core,WordPress-Docs" | ||
fi | ||
|
||
gosu rtbot bash -c "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$GITHUB_SHA --token=$USER_GITHUB_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard --lint=true" |