diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-05-25 09:33:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-25 01:33:31 +0000 |
commit | 93c6a9a652460f89fc719024c435cacbb235d302 (patch) | |
tree | 1dc3c6a60fe619580fcc949f4b2653f1e722a658 /.github | |
parent | d7e669c3719f74340096c212a1228bb11c028652 (diff) | |
download | gitea-93c6a9a652460f89fc719024c435cacbb235d302.tar.gz gitea-93c6a9a652460f89fc719024c435cacbb235d302.zip |
Use file filters action instead of Github's files filter (#24877)
Inspired by
https://github.com/go-gitea/gitea/pull/24530#issuecomment-1558815301
This PR use a file filter action to do different CI jobs according
changed files types. All types are defined in
`.github/file-filters.yml`. Now there are 4 types, `docs`, `backend`,
`frontend` and `build`. Then if a PR only changed docs files, those CI
jobs which passed the conditions will run, and other types are also like
this.
---------
Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to '.github')
-rw-r--r-- | .github/file-filters.yml | 15 | ||||
-rw-r--r-- | .github/workflows/files-changed.yml | 32 | ||||
-rw-r--r-- | .github/workflows/pull-compliance-docs.yml | 8 | ||||
-rw-r--r-- | .github/workflows/pull-compliance-docsignore.yml | 43 | ||||
-rw-r--r-- | .github/workflows/pull-compliance.yml | 18 | ||||
-rw-r--r-- | .github/workflows/pull-db-tests-docsignore.yml | 38 | ||||
-rw-r--r-- | .github/workflows/pull-db-tests.yml | 18 | ||||
-rw-r--r-- | .github/workflows/pull-docker-dryrun-docsignore.yml | 13 | ||||
-rw-r--r-- | .github/workflows/pull-docker-dryrun.yml | 8 | ||||
-rw-r--r-- | .github/workflows/pull-e2e-tests-docsignore.yml | 13 | ||||
-rw-r--r-- | .github/workflows/pull-e2e-tests.yml | 8 |
11 files changed, 92 insertions, 122 deletions
diff --git a/.github/file-filters.yml b/.github/file-filters.yml new file mode 100644 index 0000000000..26231c9364 --- /dev/null +++ b/.github/file-filters.yml @@ -0,0 +1,15 @@ +docs: &docs + - "**/*.md" + - "docs/**" + +backend: &backend + - "**/*.go" + - "**/*.tmpl" + - "go.mod" + - "go.sum" + +frontend: &frontend + - "**/*.js" + - "web_src/**" + - "package.json" + - "package-lock.json" diff --git a/.github/workflows/files-changed.yml b/.github/workflows/files-changed.yml new file mode 100644 index 0000000000..2efd676719 --- /dev/null +++ b/.github/workflows/files-changed.yml @@ -0,0 +1,32 @@ +name: files changed + +on: + workflow_call: + outputs: + docs: + description: "whether docs files changed" + value: ${{ jobs.files-changed.outputs.docs }} + backend: + description: "whether backend files changed" + value: ${{ jobs.files-changed.outputs.backend }} + frontend: + description: "whether frontend files changed" + value: ${{ jobs.files-changed.outputs.frontend }} + +jobs: + files-changed: + name: detect which files changed + runs-on: ubuntu-latest + timeout-minutes: 3 + # Map a step output to a job output + outputs: + docs: ${{ steps.changes.outputs.docs }} + backend: ${{ steps.changes.outputs.backend }} + frontend: ${{ steps.changes.outputs.frontend }} + steps: + - uses: actions/checkout@v3 + - name: Check for backend file changes + uses: dorny/paths-filter@v2 + id: changes + with: + filters: .github/file-filters.yml diff --git a/.github/workflows/pull-compliance-docs.yml b/.github/workflows/pull-compliance-docs.yml index 44db6d67af..be0ecc3220 100644 --- a/.github/workflows/pull-compliance-docs.yml +++ b/.github/workflows/pull-compliance-docs.yml @@ -2,16 +2,18 @@ name: compliance-docs on: pull_request: - paths: - - "docs/**" - - "*.md" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: + files-changed: + uses: ./.github/workflows/files-changed.yml + compliance-docs: + if: needs.files-changed.outputs.docs == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/pull-compliance-docsignore.yml b/.github/workflows/pull-compliance-docsignore.yml deleted file mode 100644 index ea0619e122..0000000000 --- a/.github/workflows/pull-compliance-docsignore.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: compliance - -on: - pull_request: - paths: - - "docs/**" - - "*.md" - -jobs: - compliance-docs: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - lint-backend: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - lint-go-windows: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - lint-go-gogit: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - checks-backend: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - frontend: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - backend: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" diff --git a/.github/workflows/pull-compliance.yml b/.github/workflows/pull-compliance.yml index ace2b15a9b..e108379b30 100644 --- a/.github/workflows/pull-compliance.yml +++ b/.github/workflows/pull-compliance.yml @@ -2,16 +2,18 @@ name: compliance on: pull_request: - paths-ignore: - - "docs/**" - - "*.md" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: + files-changed: + uses: ./.github/workflows/files-changed.yml + lint-backend: + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -24,6 +26,8 @@ jobs: env: TAGS: bindata sqlite sqlite_unlock_notify lint-go-windows: + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -38,6 +42,8 @@ jobs: GOOS: windows GOARCH: amd64 lint-go-gogit: + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -50,6 +56,8 @@ jobs: env: TAGS: bindata gogit sqlite sqlite_unlock_notify checks-backend: + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -60,6 +68,8 @@ jobs: - run: make deps-backend deps-tools - run: make --always-make checks-backend # ensure the "go-licenses" make target runs frontend: + if: needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -70,6 +80,8 @@ jobs: - run: make lint-frontend - run: make checks-frontend backend: + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/pull-db-tests-docsignore.yml b/.github/workflows/pull-db-tests-docsignore.yml deleted file mode 100644 index c04f763c3e..0000000000 --- a/.github/workflows/pull-db-tests-docsignore.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: db-tests - -on: - pull_request: - paths: - - "docs/**" - - "*.md" - -jobs: - test-pgsql: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - test-sqlite: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - test-unit: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - test-mysql5: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - test-mysql8: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" - - test-mssql: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index b3b02f15ca..cf08da1512 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -2,16 +2,18 @@ name: db-tests on: pull_request: - paths-ignore: - - "docs/**" - - "*.md" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: + files-changed: + uses: ./.github/workflows/files-changed.yml + test-pgsql: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest services: pgsql: @@ -56,6 +58,8 @@ jobs: USE_REPO_TEST_DIR: 1 test-sqlite: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -75,6 +79,8 @@ jobs: USE_REPO_TEST_DIR: 1 test-unit: + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed runs-on: ubuntu-latest services: mysql: @@ -138,6 +144,8 @@ jobs: GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }} test-mysql5: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest services: mysql: @@ -180,6 +188,8 @@ jobs: TEST_INDEXER_CODE_ES_URL: "http://elastic:changeme@elasticsearch:9200" test-mysql8: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest services: mysql8: @@ -207,6 +217,8 @@ jobs: USE_REPO_TEST_DIR: 1 test-mssql: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest services: mssql: diff --git a/.github/workflows/pull-docker-dryrun-docsignore.yml b/.github/workflows/pull-docker-dryrun-docsignore.yml deleted file mode 100644 index 7c74efb34a..0000000000 --- a/.github/workflows/pull-docker-dryrun-docsignore.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: docker-dryrun - -on: - pull_request: - paths: - - "docs/**" - - "*.md" - -jobs: - docker-dryrun: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" diff --git a/.github/workflows/pull-docker-dryrun.yml b/.github/workflows/pull-docker-dryrun.yml index c3cdefc7a7..89b0c5253c 100644 --- a/.github/workflows/pull-docker-dryrun.yml +++ b/.github/workflows/pull-docker-dryrun.yml @@ -2,16 +2,18 @@ name: docker-dryrun on: pull_request: - paths-ignore: - - "docs/**" - - "*.md" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: + files-changed: + uses: ./.github/workflows/files-changed.yml + docker-dryrun: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: docker/setup-buildx-action@v2 diff --git a/.github/workflows/pull-e2e-tests-docsignore.yml b/.github/workflows/pull-e2e-tests-docsignore.yml deleted file mode 100644 index e809af7216..0000000000 --- a/.github/workflows/pull-e2e-tests-docsignore.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: e2e-tests - -on: - pull_request: - paths: - - "docs/**" - - "*.md" - -jobs: - test-e2e: - runs-on: ubuntu-latest - steps: - - run: echo "No build required" diff --git a/.github/workflows/pull-e2e-tests.yml b/.github/workflows/pull-e2e-tests.yml index 611a6b0741..cf6af401f5 100644 --- a/.github/workflows/pull-e2e-tests.yml +++ b/.github/workflows/pull-e2e-tests.yml @@ -2,16 +2,18 @@ name: e2e-tests on: pull_request: - paths-ignore: - - "docs/**" - - "*.md" concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: + files-changed: + uses: ./.github/workflows/files-changed.yml + test-e2e: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.frontend == 'true' + needs: files-changed runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 |