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

Use file filters action instead of Github's files filter #24877

Merged
merged 12 commits into from
May 25, 2023
15 changes: 15 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
docs: &docs
- "**/*.md"
- "docs/**"

backend: &backend
- "**/*.go"
lunny marked this conversation as resolved.
Show resolved Hide resolved
- "**/*.tmpl"
- "go.mod"
- "go.sum"

frontend: &frontend
- "**/*.js"
- "web_src/**"
- "package.json"
- "package-lock.json"
32 changes: 32 additions & 0 deletions .github/workflows/files-changed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: files changed

on:
workflow_call:
outputs:
docs:
description: "wehther docs files changed"
value: ${{ jobs.files-changed.outputs.docs }}
backend:
description: "wehther backend files changed"
value: ${{ jobs.files-changed.outputs.backend }}
frontend:
description: "wehther frontend files changed"
value: ${{ jobs.files-changed.outputs.frontend }}
silverwind marked this conversation as resolved.
Show resolved Hide resolved

jobs:
files-changed:
name: detect what files changed
silverwind marked this conversation as resolved.
Show resolved Hide resolved
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
8 changes: 5 additions & 3 deletions .github/workflows/pull-compliance-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/pull-compliance-docsignore.yml

This file was deleted.

18 changes: 15 additions & 3 deletions .github/workflows/pull-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/pull-db-tests-docsignore.yml

This file was deleted.

18 changes: 15 additions & 3 deletions .github/workflows/pull-db-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/pull-docker-dryrun-docsignore.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/pull-docker-dryrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/pull-e2e-tests-docsignore.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/pull-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.6.0
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@latest
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@latest

DOCKER_IMAGE ?= gitea/gitea
DOCKER_TAG ?= latest
Expand Down Expand Up @@ -199,6 +200,7 @@ help:
@echo " - deps-tools install tool dependencies"
@echo " - lint lint everything"
@echo " - lint-fix lint everything and fix issues"
@echo " - lint-actions lint action workflow files"
@echo " - lint-frontend lint frontend files"
@echo " - lint-frontend-fix lint frontend files and fix issues"
@echo " - lint-backend lint backend files"
Expand Down Expand Up @@ -411,6 +413,10 @@ lint-go-vet:
lint-editorconfig:
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows

.PHONY: lint-actions
lint-actions:
$(GO) run $(ACTIONLINT_PACKAGE)

.PHONY: watch
watch:
bash build/watch.sh
Expand Down Expand Up @@ -908,6 +914,7 @@ deps-tools:
$(GO) install $(XGO_PACKAGE)
$(GO) install $(GO_LICENSES_PACKAGE)
$(GO) install $(GOVULNCHECK_PACKAGE)
$(GO) install $(ACTIONLINT_PACKAGE)

node_modules: package-lock.json
npm install --no-save
Expand Down