From b3647d0b1d02302e33af0bcf3c942169e9f4e856 Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Mon, 13 May 2024 23:01:32 +0200 Subject: [PATCH] Refactor GitHub actions to only trigger on specific file changes --- .github/workflows/artifacthub.yaml | 6 +-- .github/workflows/e2e.yaml | 26 ++++++++++++ .github/workflows/go.yaml | 35 ++++++++++++++++ .github/workflows/helm.yaml | 25 +++++++++++ .github/workflows/release.yaml | 3 -- .github/workflows/tests.yaml | 67 ------------------------------ 6 files changed, 88 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/e2e.yaml create mode 100644 .github/workflows/go.yaml create mode 100644 .github/workflows/helm.yaml delete mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/artifacthub.yaml b/.github/workflows/artifacthub.yaml index f1501626..ca9e01c0 100644 --- a/.github/workflows/artifacthub.yaml +++ b/.github/workflows/artifacthub.yaml @@ -1,14 +1,12 @@ name: artifacthub - on: push: branches: ["main"] - paths: ["charts/spegel/artifacthub-repo.yml"] - + paths: + - "charts/spegel/artifacthub-repo.yml" permissions: contents: read packages: write - jobs: release: runs-on: ubuntu-latest diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 00000000..f46c293c --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,26 @@ +name: e2e +on: + pull_request: + paths: + - "**.go" + - "go.mod" + - "go.sum" + - "Dockerfile" + - "test/**" + - "charts/**" +jobs: + test: + needs: lint + runs-on: ubuntu-latest + strategy: + matrix: + cni: [iptables, iptables-ipv6, ipvs] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run e2e + run: make e2e CNI=${{ matrix.cni }} diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml new file mode 100644 index 00000000..ae7ca264 --- /dev/null +++ b/.github/workflows/go.yaml @@ -0,0 +1,35 @@ +name: go +on: + pull_request: + paths: + - "**.go" + - "go.mod" + - "go.sum" + - ".golangci.yaml" +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Setup golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.58.0 + args: --timeout 3m0s + unit: + needs: lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run tests + run: make test diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml new file mode 100644 index 00000000..2bff1e6d --- /dev/null +++ b/.github/workflows/helm.yaml @@ -0,0 +1,25 @@ +name: helm +on: + pull_request: + paths: + - "charts/**" +jobs: + docs: + needs: lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run helm-docs + run: make helm-docs + - name: Check if working tree is dirty + run: | + if [[ $(git diff --stat) != '' ]]; then + git diff + echo 'run make helm-docs and commit changes' + exit 1 + fi diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2266dec9..687720ed 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,14 +1,11 @@ name: release - on: release: types: [published] - permissions: contents: read packages: write id-token: write - jobs: release: runs-on: ubuntu-latest diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml deleted file mode 100644 index dea844a6..00000000 --- a/.github/workflows/tests.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: tests -on: - pull_request: - push: - branches: - - main -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Setup golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - version: v1.58.0 - args: --timeout 3m0s - unit: - needs: lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Run tests - run: make test - e2e: - needs: lint - runs-on: ubuntu-latest - strategy: - matrix: - cni: [iptables, iptables-ipv6, ipvs] - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Run e2e - run: make e2e CNI=${{ matrix.cni }} - helm-docs: - needs: lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Run helm-docs - run: make helm-docs - - name: Check if working tree is dirty - run: | - if [[ $(git diff --stat) != '' ]]; then - git diff - echo 'run make helm-docs and commit changes' - exit 1 - fi