Revise GitHub workflows #2 (#9240)

* GitHub workflow revision #2

* Add a few comments

* Add and fix comments

* Move kodiak config into .github

To not overflow the root directory

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
Pascal Jufer
2021-11-01 16:05:13 +01:00
committed by GitHub
parent b3a1435b29
commit 6994bba791
8 changed files with 69 additions and 46 deletions

5
.github/.kodiak.toml vendored Normal file
View File

@@ -0,0 +1,5 @@
version = 1
[merge]
method = "squash"
delete_branch_on_merge = true

View File

@@ -1,37 +0,0 @@
name: Auto-Merge Translations from Crowdin
on:
pull_request:
branches:
- main
# Only run if pull request includes changes in translation files
paths:
- 'app/src/lang/translations/*.yaml'
jobs:
auto-merge:
name: Auto-Merge
# Only auto-merge if it looks like an actual pull request from Crowdin
if: github.event.pull_request.user.login == 'rijkvanzanten' && github.event.pull_request.title == 'New Crowdin updates' && github.head_ref == 'translations'
runs-on: ubuntu-latest
steps:
- name: Wait for checks
uses: lewagon/wait-on-check-action@v1.1.1
# Ensure this step doesn't run too long
timeout-minutes: 8
# Still try to auto-merge if this step has failed
continue-on-error: true
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha }}
running-workflow-name: Auto-Merge
wait-interval: 15
allowed-conclusions: success,skipped,cancelled,failure
- name: Auto-Merge
uses: pascalgn/automerge-action@v0.14.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_LABELS: ''
UPDATE_LABELS: ''
MERGE_METHOD: squash

View File

@@ -1,3 +1,5 @@
### Continuous Integration
# Entrypoint for all CI related jobs
name: CI
on:
@@ -9,47 +11,57 @@ on:
- main
jobs:
# Check whether workflow is skippable
pre_check:
name: Pre-Check
runs-on: ubuntu-latest
outputs:
# Returns 'true' if workflow is skippable for one of the following reasons:
# - Exact same files have been successfully checked in older run
# - Only files that do not require checks have been changed (paths_ignore)
# - Only files that do not require checks have been changed (paths_ignore) and older commits were successful
should_skip: ${{ steps.skip_check.outputs.should_skip }}
skipped_by: ${{ steps.skip_check.outputs.skipped_by }}
steps:
- name: Check if workflow is skippable
id: skip_check
uses: fkirc/skip-duplicate-actions@master
# Switch back to fkirc/skip-duplicate-actions once changes have been merged
uses: paescuj/skip-duplicate-actions@revision
# Run all the jobs if the pre-check should fail for any reason
# (the pre-check will be marked as 'passed', better solution pending at https://github.com/actions/toolkit/issues/399)
# (setting this on step-level makes sure the pre-check will still be marked as 'passed',
# better solution pending at https://github.com/actions/toolkit/issues/399)
continue-on-error: true
with:
# Cancel outdated workflow-runs
cancel_others: 'true'
# Ignore changes in the following files
paths_ignore: '["app/src/lang/translations/*.yaml"]'
lint:
name: Lint
needs: pre_check
if: needs.pre_check.outputs.should_skip != 'true'
uses: directus/directus/.github/workflows/lint.yml@main
with:
should_skip: ${{ needs.pre_check.outputs.should_skip }}
codeql_analysis:
name: CodeQL Analysis
needs: pre_check
if: needs.pre_check.outputs.should_skip != 'true'
uses: directus/directus/.github/workflows/codeql-analysis.yml@main
with:
should_skip: ${{ needs.pre_check.outputs.should_skip }}
unit_tests:
name: Unit Tests
needs: pre_check
if: needs.pre_check.outputs.should_skip != 'true'
uses: directus/directus/.github/workflows/unit-tests.yml@main
with:
should_skip: ${{ needs.pre_check.outputs.should_skip }}
# Run end-to-end tests only on push events to 'main' branch for now
# (not skippable by successful workflow run which wasn't triggered by 'push' event)
e2e_tests:
name: End-to-End Tests
needs: pre_check
# Only run on push events (on main branch) for now
if: github.event_name == 'push' && needs.pre_check.outputs.should_skip != 'true'
uses: directus/directus/.github/workflows/e2e-tests.yml@main
with:
should_skip: ${{ github.event_name != 'push' || (needs.pre_check.outputs.skipped_by && fromJSON(needs.pre_check.outputs.skipped_by).event == 'push') }}

View File

@@ -2,12 +2,17 @@ name: CodeQL Analysis
on:
workflow_call:
inputs:
should_skip:
required: false
type: string
schedule:
- cron: '42 23 * * 5'
jobs:
analyze:
name: Analyze
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
permissions:
actions: read

View File

@@ -3,9 +3,15 @@ name: End-to-End Tests
on:
workflow_call:
workflow_dispatch:
inputs:
should_skip:
required: false
type: string
jobs:
test:
name: Test
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -62,3 +68,13 @@ jobs:
run: |
docker tag directus-test-image $CACHED_IMAGE
docker push $CACHED_IMAGE || true
result:
name: Result
if: inputs.should_skip != 'true' && always()
runs-on: ubuntu-latest
needs: test
steps:
- name: Mark result as failed
if: needs.test.result != 'success'
run: exit 1

View File

@@ -2,10 +2,15 @@ name: Lint
on:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
lint:
name: Lint
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository

View File

@@ -2,10 +2,15 @@ name: Unit Tests
on:
workflow_call:
inputs:
should_skip:
required: false
type: string
jobs:
test:
name: Test (Node.js ${{ matrix.node-version }})
name: Test
if: inputs.should_skip != 'true'
runs-on: ubuntu-latest
strategy:
matrix:
@@ -31,3 +36,13 @@ jobs:
run: npm run test
env:
SECRET: TEST_SECRET
result:
name: Result
if: inputs.should_skip != 'true' && always()
runs-on: ubuntu-latest
needs: test
steps:
- name: Mark result as failed
if: needs.test.result != 'success'
run: exit 1

View File

@@ -1,3 +1,5 @@
files:
- source: /app/src/lang/translations/en-US.yaml
translation: /app/src/lang/translations/%locale%.yaml
pull_request_labels:
- automerge