Skip to content

Commit

Permalink
refactor(ci): reduce complexity in required workflows (#3925)
Browse files Browse the repository at this point in the history
* refactor(ci): builds upon work in tests to reduce complexity in requiring workflows

* fix: tweaks and missing outputs

* fix: make sure the new workflows actually run

* fix: consistency with non-required testing image
  • Loading branch information
GenPage committed Nov 6, 2023
1 parent 9395be2 commit 4cea3b9
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 187 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/atlantis-image-required.yml

This file was deleted.

42 changes: 36 additions & 6 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,43 @@ on:
push:
branches:
- 'main'
- 'releases-**'
tags:
- v*.*.* # stable release like, v0.19.2
- v*.*.*-pre.* # pre release like, v0.19.0-pre.calendardate
pull_request:
paths:
- 'Dockerfile'
- 'docker-entrypoint.sh'
- '.github/workflows/atlantis-image.yml'
- '**.go'
- 'go.*'
branches:
- 'main'
- 'releases-**'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
changes:
outputs:
should-run-build: ${{ steps.changes.outputs.src == 'true' }}
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'Dockerfile'
- 'docker-entrypoint.sh'
- '.github/workflows/atlantis-image.yml'
- '**.go'
- 'go.*'
build:
needs: [changes]
if: needs.changes.outputs.should-run-build == 'true'
name: Build Image
strategy:
matrix:
image_type: [alpine, debian]
Expand Down Expand Up @@ -123,3 +142,14 @@ jobs:
target: ${{ matrix.image_type }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}

skip-build:
needs: [changes]
if: needs.changes.outputs.should-run-build == 'false'
name: Build Image
strategy:
matrix:
image_type: [alpine, debian]
runs-on: ubuntu-22.04
steps:
- run: 'echo "No build required"'
40 changes: 0 additions & 40 deletions .github/workflows/codeql-required.yml

This file was deleted.

45 changes: 35 additions & 10 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,44 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
paths:
- '**.go'
- '**.js'
branches:
- 'main'
- 'releases-**'
pull_request:
# The branches below must be a subset of the branches above
types:
- opened
- reopened
- synchronize
- ready_for_review
branches: [ "main" ]
paths:
- '**.go'
- '**.js'
branches:
- 'main'
- 'releases-**'

schedule:
- cron: '17 9 * * 5'

jobs:
changes:
outputs:
should-run-analyze: ${{ steps.changes.outputs.src == 'true' }}
if: github.event.pull_request.draft == false
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '**.go'
- '**.js4'
analyze:
needs: [changes]
name: Analyze
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && needs.changes.outputs.should-run-analyze == 'true'
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
Expand Down Expand Up @@ -87,3 +101,14 @@ jobs:
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"

skip-analyze:
needs: [changes]
if: needs.changes.outputs.should-run-analyze == 'false'
name: Analyze
strategy:
matrix:
language: [ 'go', 'javascript' ]
runs-on: ubuntu-22.04
steps:
- run: 'echo "No build required"'
32 changes: 0 additions & 32 deletions .github/workflows/lint-required.yml

This file was deleted.

36 changes: 29 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,46 @@ on:
- ready_for_review
branches:
- "main"
paths:
- '**.go'
- 'go.*'
- '.github/workflows/lint.yml'
- '.golangci.yml'
- 'releases-**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
golangci-lint:
changes:
outputs:
should-run-linting: ${{ steps.changes.outputs.go == 'true' }}
if: github.event.pull_request.draft == false
name: runner / golangci-lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
go:
- '**.go'
- 'go.*'
- '.github/workflows/lint.yml'
- '.golangci.yml'
golangci-lint:
needs: [changes]
if: github.event.pull_request.draft == false && needs.changes.outputs.should-run-linting == 'true'
name: Linting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
tool_name: golangci-lint

skip-lint:
needs: [changes]
if: needs.changes.outputs.should-run-linting == 'false'
name: Linting
runs-on: ubuntu-22.04
steps:
- run: 'echo "No build required"'
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/stale@v8
with:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ name: tester
on:
push:
branches:
- "main"
- 'main'
- 'releases-**'
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- "main"
- 'main'
- 'releases-**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -36,7 +38,7 @@ jobs:
test:
needs: [changes]
if: needs.changes.outputs.should-run-tests == 'true'
name: runner / gotest
name: Tests
runs-on: ubuntu-22.04
container: ghcr.io/runatlantis/testing-env:latest
steps:
Expand All @@ -47,7 +49,7 @@ jobs:
skip-test:
needs: [changes]
if: needs.changes.outputs.should-run-tests == 'false'
name: runner / gotest
name: Tests
runs-on: ubuntu-22.04
steps:
- run: 'echo "No build required"'
Loading

0 comments on commit 4cea3b9

Please sign in to comment.