From 59e05697b9336f3399e7d1d88c72d452b4f791e1 Mon Sep 17 00:00:00 2001 From: Dale Morgan Date: Wed, 10 Jul 2024 11:04:58 +0100 Subject: [PATCH 1/2] Simplify the workflows # What Simplify the repo's workflows: - only try to trigger a release on merge to default branch (e.g. `main`) if the version file has been updated and inline tests have been successful - `Tests` workflow is still a required check, but no longer triggers a `workflow_run` `completed` for release --- .github/workflows/release_gem.yml | 16 +++++++++------- .github/workflows/tests.yml | 14 +------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release_gem.yml b/.github/workflows/release_gem.yml index 8df5c8f..d841755 100644 --- a/.github/workflows/release_gem.yml +++ b/.github/workflows/release_gem.yml @@ -1,17 +1,15 @@ name: Build and Release Gem on: - # This event will only trigger a workflow run if the workflow file is on the default branch. - # https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_run - workflow_run: - workflows: ["Tests"] - types: - - completed + push: + branches: + - main + paths: + - lib/aws_local_config_parser/version.rb jobs: release: name: Release to RubyGems.org runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }} permissions: id-token: write contents: write @@ -23,6 +21,10 @@ jobs: with: bundler-cache: true + # Run tests and rubocop + - name: Run tests and rubocop + run: bundle exec rake + # Release - name: Release to RubyGems.org uses: rubygems/release-gem@v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b8bde4..7e3de4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,18 +1,6 @@ name: Tests on: - push: - branches: - - main - paths-ignore: - - .editorconfig - - .gitignore - - .vscode/** - - bin/** - - Brewfile - - lefthook.yml - - LICENSE - - README.md pull_request: jobs: @@ -25,5 +13,5 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - - name: Run the default task + - name: Run tests and rubocop run: bundle exec rake From 688fa7d2a38ffc12afb04a28fa4aa364ce9c03a9 Mon Sep 17 00:00:00 2001 From: Dale Morgan Date: Wed, 10 Jul 2024 11:11:52 +0100 Subject: [PATCH 2/2] Adding actionlint and workflow --- .github/workflows/actionlint.yml | 16 ++++++++++++++++ Brewfile | 1 + README.md | 1 + lefthook.yml | 3 +++ 4 files changed, 21 insertions(+) create mode 100644 .github/workflows/actionlint.yml diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 0000000..eb4c390 --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,16 @@ +name: Lint workflow files + +on: + pull_request: + paths: + - '.github/workflows/*.yml' + - '.github/workflows/*.yaml' + +permissions: + pull-requests: write + contents: read + +jobs: + actionlint: + uses: fac/hermod/.github/workflows/actionlint.yml@master + secrets: inherit diff --git a/Brewfile b/Brewfile index e3462e1..cf1d205 100644 --- a/Brewfile +++ b/Brewfile @@ -1 +1,2 @@ +brew 'actionlint' brew 'lefthook' diff --git a/README.md b/README.md index 32bc4bf..20da3d3 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ config.all_sso_sessions ## Making a commit [Lefthook](https://github.com/evilmartians/lefthook/) has [been configured](./lefthook.yml) with pre-commit checks to: - run `rubocop` for any `ruby` files +- run `actionlint` for any GitHub workflow files If for some reason it's necessary, it's possible to temporarily skip `lefthook` with: `LEFTHOOK=0 git commit`. diff --git a/lefthook.yml b/lefthook.yml index 14e15fd..6faa58f 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -3,6 +3,9 @@ pre-commit: parallel: true commands: + actionlint: + glob: ".github/workflows/*.{yml,yaml}" + run: actionlint {staged_files} ruby-lint: glob: "*.rb" run: bundle exec rubocop {staged_files}