Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: trigger integration tests from pr comment #1409

Merged
merged 6 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 110 additions & 22 deletions .github/workflows/full_suite_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,87 @@ on:
schedule:
- cron: '0 0 * * 1-5' # At 00:00 on every day-of-week from Monday through Friday
workflow_dispatch: # or manually
issue_comment:
types: [created] # or by comment

jobs:
run-it-full-suite:
if: github.ref == 'refs/heads/master' # for now we want this workflow to run only on master, to be removed once support for different branches is implemented
cancel_previous:
if: ${{ github.event_name != 'issue_comment'}}
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.5.0
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: '${{ secrets.GITHUB_TOKEN }}'

should_run_it:
runs-on: ubuntu-latest
outputs:
run_integration_tests: ${{ steps.should-run-step.outputs.should_run }}
pr_number: ${{ steps.pr_number.outputs.number }}
steps:
- name: Get PR number
id: pr_number
if: ${{ github.event_name == 'issue_comment'}}
run: |
PR_URL="${{ github.event.issue.pull_request.url }}"
PR_NUMBER=${PR_URL##*/}
echo "::set-output name=number::$PR_NUMBER"
- uses: khan/pull-request-comment-trigger@master
if: ${{ github.event_name == 'issue_comment'}}
id: check_issue_comment
with:
trigger: '@flank-it'
reaction: eyes
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Check if integrations tests should run
id: should-run-step
env:
run_it: ${{ steps.check_issue_comment.outputs.triggered == 'true'|| github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }}
run : |
echo "event name: ${{ github.event_name }}"
echo "issue command found: ${{ steps.check_issue_comment.outputs.triggered == 'true' }}"
echo '::set-output name=should_run::${{ env.run_it }}'
integration-tests-post-link:
runs-on: ubuntu-latest
needs: [ should_run_it ]
if: github.event_name == 'issue_comment' && needs.should_run_it.outputs.run_integration_tests == 'true'
outputs:
comment_id: ${{ steps.couc.outputs.comment-id }}
steps:
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: 'YYYY-MM-DD HH:mm:ss'
utcOffset: "+00:00"
- name: Create comment that tests were triggered
uses: peter-evans/create-or-update-comment@v1
id: couc
with:
issue-number: ${{ needs.should_run_it.outputs.pr_number }}
body: |
**Integration tests were triggered at ${{ steps.current-time.outputs.formattedTime }}, you could track them [here](https://github.com/Flank/flank/actions/runs/${{ github.run_id }})**
reactions: rocket

run-it-full-suite:
needs: [ should_run_it ]
if: needs.should_run_it.outputs.run_integration_tests == 'true'
runs-on: ubuntu-latest
outputs:
job_status: ${{ job.status }}
build-scan-url: ${{ steps.run-it.outputs.build-scan-url }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: true

- name: Download flankScripts and add it to PATH
- name: Checkout Pull Request
if: github.event_name == 'issue_comment'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew :flank-scripts:download
echo "./flank-scripts/bash" >> $GITHUB_PATH
gh pr checkout ${{ needs.should_run_it.outputs.pr_number }}

- uses: actions/cache@v2
with:
Expand All @@ -40,15 +101,6 @@ jobs:
mkdir -p "$GCLOUD_DIR"
echo "$GCLOUD_KEY" | base64 --decode > "$GCLOUD_DIR/application_default_credentials.json"

- name: Gradle clean build
uses: eskatos/gradle-command-action@v1
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REF: ${{ github.ref }}
with:
arguments: "clean build"

- name: Gradle integration tests
uses: eskatos/gradle-command-action@v1
id: run-it
Expand All @@ -58,11 +110,47 @@ jobs:
with:
arguments: "integrationTests"

process-results:
needs: [ run-it-full-suite ]
runs-on: ubuntu-latest
if: always() && github.event_name != 'issue_comment'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download flankScripts and add it to PATH
run: |
./gradlew :flank-scripts:download
echo "./flank-scripts/bash" >> $GITHUB_PATH

- name: Process IT results
if: always()
run: |
flankScripts integration processResults \
--result ${{ job.status }} \
--url ${{ steps.run-it.outputs.build-scan-url }} \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--run-id ${{ github.run_id }}
--result ${{ needs.run-it-full-suite.outputs.job_status }} \
--url ${{ needs.run-it-full-suite.outputs.build-scan-url }} \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--run-id ${{ github.run_id }}

post-comment_with_results:
needs: [ run-it-full-suite, integration-tests-post-link ]
runs-on: ubuntu-latest
if: always() && github.event_name == 'issue_comment'
steps:
- name: Update comment on failure
if: ${{ needs.run-it-full-suite.outputs.job_status == 'failure' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ needs.integration-tests-post-link.outputs.comment_id }}
edit-mode: replace
body: |
**Integration tests failed, you could see results [here](https://github.com/Flank/flank/actions/runs/${{ github.run_id }})**
reactions: '-1'

- name: Update comment on success
if: ${{ needs.run-it-full-suite.outputs.job_status == 'success' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ needs.integration-tests-post-link.outputs.comment_id }}
edit-mode: replace
body: |
**Integration tests succeed, you could see results [here](https://github.com/Flank/flank/actions/runs/${{ github.run_id }})**
reactions: '+1'
4 changes: 4 additions & 0 deletions integration_tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
freeCompilerArgs = listOf("-Xinline-classes")
}
// Locally you should have flank built already, on CI we need to build it
if(System.getenv("CI") != null) {
tasks["integrationTests"].dependsOn(":test_runner:build")
}