-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from UN-OCHA/develop
Deploy 2023-02-09
- Loading branch information
Showing
22 changed files
with
2,240 additions
and
237 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,213 @@ | ||
name: Run tests | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup PHP with PECL extension | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.0 | ||
tools: composer | ||
env: | ||
fail-fast: true | ||
|
||
- name: Software versions | ||
id: versions | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
php --version && composer --version | ||
- name: Checkout Code | ||
id: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Composer Validate | ||
id: validate | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
composer validate | ||
env: | ||
fail-fast: true | ||
|
||
- name: Code Lint | ||
id: lint | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
test ! -d ./html/modules/custom || find -L ./html/modules/custom -iregex '.*\.\(php\|module\|inc\|install\)$' -print0 | xargs -0 -n 1 -P 4 php -l | ||
env: | ||
fail-fast: true | ||
|
||
- name: Configure AWS Credentials | ||
id: aws | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Login to Public ECR | ||
id: aws-login | ||
uses: docker/[email protected] | ||
with: | ||
registry: public.ecr.aws | ||
username: ${{ secrets.ECR_AWS_ACCESS_KEY_I }} | ||
password: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | ||
env: | ||
AWS_REGION: us-east-1 | ||
|
||
- name: Build Image | ||
id: build | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
make | ||
env: | ||
fail-fast: true | ||
|
||
- name: Setup Environment | ||
id: docker | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
docker-compose -f tests/docker-compose.yml up -d | ||
sleep 10 | ||
docker ps -a | ||
docker-compose -f tests/docker-compose.yml exec -w /srv/www -T drupal composer install | ||
env: | ||
fail-fast: true | ||
|
||
- name: PHPCS | ||
id: phpcs | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
docker-compose -f tests/docker-compose.yml exec -u appuser -w /srv/www -T drupal phpcs -p --report=full --standard=phpcs.xml ./html/modules/custom | ||
env: | ||
fail-fast: true | ||
|
||
- name: Install Environment | ||
id: install | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config | ||
env: | ||
fail-fast: true | ||
|
||
- name: Run tests | ||
id: tests | ||
uses: cafuego/command-output@main | ||
with: | ||
run: | | ||
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog | ||
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private | ||
docker-compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/build/logs | ||
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/build/logs | ||
docker-compose -f tests/docker-compose.yml exec -T -w /srv/www -e XDEBUG_MODE=coverage -e BROWSERTEST_OUTPUT_DIRECTORY=/srv/www/html/sites/default/files/browser_output -e DTT_BASE_URL=http://127.0.0.1 drupal ./vendor/bin/phpunit --coverage-clover /srv/www/html/build/logs/clover.xml --debug | ||
docker cp "$(docker-compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml . | ||
env: | ||
fail-fast: true | ||
|
||
- name: Monitor coverage | ||
uses: slavcodev/coverage-monitor-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
coverage_path: "clover.xml" | ||
threshold_alert: 10 | ||
threshold_warning: 50 | ||
threshold_metric: "lines" | ||
comment_footer: false | ||
|
||
- name: Find Comment | ||
uses: peter-evans/find-comment@v2 | ||
id: fc | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: Build output | ||
|
||
- name: Create or update comment | ||
uses: peter-evans/create-or-update-comment@v2 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
### Build output | ||
#### Composer Validate \`${{ steps.validate.outcome }}\` | ||
#### PHP Lint \`${{ steps.lint.outcome }}\` | ||
#### Docker Build \`${{ steps.build.outcome }}\` | ||
#### Environment Setup \`${{ steps.docker.outcome }}\` | ||
#### Site Install \`${{ steps.install.outcome }}\` | ||
#### PHP Code Sniffer \`${{ steps.phpcs.outcome }}\` | ||
<details><summary>Software Versions</summary> | ||
\`\`\`${{ steps.versions.outputs.stdout }}\`\`\` | ||
</details> | ||
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`; | ||
edit-mode: replace | ||
|
||
- name: Slack Success Notification | ||
id: slack_success | ||
if: success() | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: '${{ secrets.SLACK_CHANNEL }}' | ||
payload: | | ||
{ | ||
"text": "Tests passed for a pull request on ${{ github.repository }}", | ||
"attachments": [ | ||
{ | ||
"color": "#00FF00", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "Pull request by @${{ github.triggering_actor }} to merge _${{ github.head_ref }}_ into _${{ github.base_ref }}_ on <${{ github.repositoryUrl }}|${{ github.repository }}> passed tests (<${{ github.event.pull_request.html_url }}|Review>)" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | ||
|
||
- name: Slack Failure Notification | ||
id: slack_failure | ||
if: failure() | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: '${{ secrets.SLACK_CHANNEL }}' | ||
payload: | | ||
{ | ||
"text": "Tests failed for a pull request on ${{ github.repository }}", | ||
"attachments": [ | ||
{ | ||
"color": "#FF0000", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "Pull request by @${{ github.triggering_actor }} to merge _${{ github.head_ref }}_ into _${{ github.base_ref }}_ on <${{ github.repositoryUrl }}|${{ github.repository }}> failed tests (<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Review>)" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.