-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from alphagov/workflow-to-test-app
Create a GitHub workflow to make it easy to test a repo against rubocop-govuk changes
- Loading branch information
Showing
2 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# GitHub Workflow to allow running rubocop-govuk against an alphagov repo | ||
# to test the effects of linting rules prior to releasing the gem. | ||
# | ||
# This is expected to be called manually via the GitHub UI (https://github.com/alphagov/rubocop-govuk/actions/workflows/run-against-project.yml) | ||
# or via the GitHub CLI. | ||
name: Run against project | ||
run-name: Running rubocop-govuk (${{ inputs.git_ref }}) against ${{ inputs.alphagov_repo }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
alphagov_repo: | ||
description: 'The alphagov repository to run rubocop-govuk against' | ||
required: true | ||
type: string | ||
git_ref: | ||
description: 'Commit, tag or branch name of rubocop-govuk to use' | ||
required: true | ||
type: string | ||
default: 'main' | ||
|
||
jobs: | ||
lint_project: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cloning alphagov/${{ inputs.alphagov_repo }} | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: alphagov/${{ inputs.alphagov_repo }} | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
# We need to turn off deployment mode so that we can modify the gems | ||
- run: bundle config unset deployment | ||
- run: bundle remove rubocop-govuk | ||
# There is a `bundle add --github --ref` command we could have used, | ||
# however the output of that falls foul of our linter (how ironic). | ||
# Instead of fighting/correcting/accepting that we have this work | ||
# around of amending the gemfile ourselves and running bundle install | ||
# again. | ||
- name: Amending gemfile for rubocop-govuk (${{ inputs.git_ref }}) | ||
run: | | ||
printf '\ngem "rubocop-govuk", github: "alphagov/rubocop-govuk", ref: "${{ inputs.git_ref }}"\n' >> Gemfile | ||
- name: Install rubcop-govuk gem | ||
run: bundle install | ||
- name: Run rubocop | ||
run: | | ||
# preserve exit code if rubocop fails | ||
set -o pipefail | ||
# use tee to output to stdout and populate GitHub summary | ||
bundle exec rubocop --format markdown | tee $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters