Skip to content

Refactor GitHub Actions workflow for fixture regeneration #90

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
49 changes: 9 additions & 40 deletions .github/workflows/fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,18 @@
name: Trigger Fixture Regeneration

permissions:
contents: write
pull-requests: write

on:
pull_request:
types:
- labeled

permissions:
contents: write
pull-requests: write

jobs:
trigger_pipeline:
regenerate_fixtures:
if: github.event.label.name == 'regenerate-fixtures'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.RYAN_FIXTURE_GEN_PAT }}

- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.22.x

- uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
body: |
Triggered a [Github Actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) job to update fixtures.

- uses: actions-ecosystem/action-remove-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: regenerate-fixtures

- name: Regenerate Fixtures
run: CODECRAFTERS_RECORD_FIXTURES=true make test

- name: Update Fixtures
run: |
git config --global user.email "[email protected]"
git config --global user.name "Ryan Gang"
git remote set-url origin https://ryan-gang:${{ secrets.RYAN_FIXTURE_GEN_PAT }}@github.com/codecrafters-io/shell-tester.git
git fetch origin ${{ github.head_ref }}
git checkout ${{ github.head_ref }}
git diff --quiet || (git add . && git commit -m "ci: add regenerated fixtures" && git push)
uses: codecrafters-io/tester-utils/.github/workflows/fixtures.yml@master
with:
tester_repo: shell-tester
secrets: inherit
2 changes: 1 addition & 1 deletion internal/test_helpers/fixtures/navigation/pass
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Debug = true
[your-program] pwd is a shell builtin
[stage-9] ✓ Received expected response
[your-program] $ pwd
[your-program] /workspaces/shell-tester/internal
[your-program] /home/runner/work/shell-tester/shell-tester/internal
[stage-9] ✓ Received current working directory response
[your-program] $
[stage-9] Test passed.
Expand Down
Loading