From 77ea596c781837b688f0172c71ecabe25b2f26bb Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Mon, 16 Sep 2024 09:35:06 -0700 Subject: [PATCH] [Gitar] Apply gitar duet on top of gitar bot PRs (#8141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## About the changes When working with automated changes made by the @gitar-bot , custom automated changes may be necessary. For example, - Running lint auto-fixes - Executing code generation - Updating test snapshot files - Running internal tools Gitar recommends these in a separate CI pipeline. We call this [Gitar Duet](https://gitar.co/docs/more/custom-automated-changes/), where custom tools run alongside Gitar’s automated changes. ### Important files github ci workflow files ## Discussion points Feel free to update the workflow to modify the autofix steps --- .github/workflows/gitar-duet-action.yml | 51 +++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/gitar-duet-action.yml diff --git a/.github/workflows/gitar-duet-action.yml b/.github/workflows/gitar-duet-action.yml new file mode 100644 index 0000000000..12eb28061e --- /dev/null +++ b/.github/workflows/gitar-duet-action.yml @@ -0,0 +1,51 @@ +name: Gitar Duet + +on: + push: + branches: + - 'gitar_*' + +jobs: + gitar-duet: + if: github.event.head_commit.author.name == 'Gitar' + runs-on: ubuntu-latest + name: Gitar Duet + permissions: + contents: write # Required to update with Gitar Duet changes + + steps: + - run: | + echo '${{ toJSON(github.event) }}' + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: 'yarn' + + - name: Enable corepack + run: corepack enable + + - run: yarn install --immutable + env: + YARN_ENABLE_SCRIPTS: false + + - run: | + yarn run biome check --fix --unsafe || true # Run unsafe auto-fixes + yarn lint:fix || true # Fix linting issues + + - run: yarn test:updateSnapshot || true # Update test snapshots + + - run: | + # Undo deletes for snapshots + git reset + git diff --diff-filter=D --name-only HEAD | xargs git checkout HEAD^ -- + + - name: Run Gitar Duet Action + uses: gitarcode/gitar-duet-action@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 57ed658de2..12f19c9bee 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "test:watch": "yarn test --watch", "test:coverage": "NODE_ENV=test PORT=4243 jest --coverage --testLocationInResults --outputFile=\"coverage/report.json\" --forceExit --testTimeout=10000", "test:coverage:jest": "NODE_ENV=test PORT=4243 jest --silent --ci --json --coverage --testLocationInResults --outputFile=\"report.json\" --forceExit --testTimeout=10000", + "test:updateSnapshot": "NODE_ENV=test PORT=4243 jest --updateSnapshot --testTimeout=10000", "seed:setup": "ts-node --compilerOptions '{\"strictNullChecks\": false}' src/test/e2e/seed/segment.seed.ts", "seed:serve": "UNLEASH_DATABASE_NAME=unleash_test UNLEASH_DATABASE_SCHEMA=seed yarn run start:dev", "clean": "del-cli --force dist", @@ -247,4 +248,4 @@ ] }, "packageManager": "yarn@4.4.1" -} +} \ No newline at end of file