name: CI on: push: branches: - master pull_request: branches: - master jobs: test: name: Test on node ${{ matrix.node_version }} runs-on: ubuntu-latest strategy: matrix: node_version: [22, 24, 26] env: CI: true steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Use Node.js ${{ matrix.node_version }} uses: actions/setup-node@master with: node-version: ${{ matrix.node_version }} - name: Install pnpm uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Get pnpm cache - Set output id: pnpm-cache run: echo "{dir}={pnpm cache dir}" >> $GITHUB_OUTPUT - name: Cache pnpm uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3 with: path: ${ env.dir } key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm- - name: Install run: pnpm i --no-frozen-lockfile - name: Build run: pnpm build - name: Test run: pnpm test - name: Lint ESLint run: pnpm lint - name: Lint Prettier run: pnpm lint:prettier - name: Integration tests run: | chmod +x ./packages/cli/dist/cjs/index.js echo 2001 node ./packages/cli/dist/cjs/index.js validate './integration_tests/2001/operations/**/*.graphql' './integration_tests/2001/schema.graphql' echo 1991 node ./packages/cli/dist/cjs/index.js validate './integration_tests/1991/two-operations.js' './integration_tests/1991/schema.graphql' echo 1985 node ./packages/cli/dist/cjs/index.js introspect ./integration_tests/1985/schema.js || echo 'TODO' echo 2108 node ./packages/cli/dist/cjs/index.js introspect './integration_tests/2108/**/!(excluded)/*.graphql' --write ./2108.graphql if grep -ic "bar" ./2108.graphql then echo "Broken" && exit 1 else echo "Works" fi echo 2027 node ./packages/cli/dist/cjs/index.js diff ./integration_tests/2027/schema-before.graphql ./integration_tests/2027/schema-after.graphql --rule considerUsage --onUsage ./integration_tests/2027/unused-hotels.js echo 2088 node ./packages/cli/dist/cjs/index.js diff ./integration_tests/2088/old.graphql ./integration_tests/2088/new.graphql --rule suppressRemovalOfDeprecatedField graphql-compatibility: name: Test GraphQL ${{ matrix.graphql_version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: graphql_version: [16] env: CI: true steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - name: Use Node.js 24 uses: actions/setup-node@master with: node-version: 24 - name: Install pnpm uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Install run: pnpm i --no-frozen-lockfile - name: Test GraphQL ${{ matrix.graphql_version }} run: pnpm exec vitest run --mode graphql-${{ matrix.graphql_version }} # Users consume action/index.js straight from master, so the bundle must match # the release PR's dependency/version bumps. The push uses BOT_GITHUB_TOKEN so # CI runs on the bundle commit. That rerun finds action/ unchanged and pushes # nothing, so this cannot loop. rebuild-action: name: Rebuild Action bundle if: github.event_name == 'pull_request' && github.head_ref == 'changeset-release/master' && github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest permissions: contents: write concurrency: group: rebuild-action-${{ github.head_ref }} cancel-in-progress: true env: CI: true steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 with: ref: ${{ github.head_ref }} token: ${{ secrets.BOT_GITHUB_TOKEN }} - name: Use Node.js uses: actions/setup-node@master with: node-version-file: .node-version - name: Install pnpm uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Install run: pnpm i --no-frozen-lockfile - name: Build run: pnpm build - name: Build Action bundle run: pnpm action - name: Commit and push bundle if changed run: | if [ -n "$(git status --porcelain action/)" ]; then git config user.name "TheGuildBot" git config user.email "59414373+theguild-bot@users.noreply.github.com" git add action/ git commit -m "chore(action): rebuild bundle" git push else echo "Action bundle is up to date" fi