|
| 1 | +name: Decrease studio lint ratchet baselines |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * SUN' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + decrease-baselines: |
| 14 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 18 | + with: |
| 19 | + sparse-checkout: | |
| 20 | + .github |
| 21 | + apps/studio |
| 22 | + packages |
| 23 | +
|
| 24 | + - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 25 | + name: Install pnpm |
| 26 | + with: |
| 27 | + run_install: false |
| 28 | + |
| 29 | + - name: Use Node.js |
| 30 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 31 | + with: |
| 32 | + node-version-file: '.nvmrc' |
| 33 | + cache: 'pnpm' |
| 34 | + |
| 35 | + - name: Install deps |
| 36 | + run: pnpm install --frozen-lockfile |
| 37 | + |
| 38 | + - name: Decrease ESLint ratchet baselines and open PR |
| 39 | + env: |
| 40 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 42 | + run: | |
| 43 | + set -eo pipefail |
| 44 | + DEFAULT_BRANCH=${DEFAULT_BRANCH:-master} |
| 45 | +
|
| 46 | + BRANCH="bot/decrease-eslint-ratchet-baselines" |
| 47 | +
|
| 48 | + git fetch origin "$DEFAULT_BRANCH" --depth=1 |
| 49 | + if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then |
| 50 | + git fetch origin "$BRANCH":"$BRANCH" --depth=1 |
| 51 | + git switch "$BRANCH" |
| 52 | + git reset --hard "origin/$DEFAULT_BRANCH" |
| 53 | + else |
| 54 | + git switch --create "$BRANCH" "origin/$DEFAULT_BRANCH" |
| 55 | + fi |
| 56 | +
|
| 57 | + pnpm --filter studio run lint:ratchet --decrease-baselines |
| 58 | +
|
| 59 | + if git diff --quiet; then |
| 60 | + echo "No baseline updates detected." |
| 61 | + exit 0 |
| 62 | + fi |
| 63 | +
|
| 64 | + git config user.name 'github-actions[bot]' |
| 65 | + git config user.email 'github-actions[bot]@users.noreply.github.com' |
| 66 | +
|
| 67 | + git add apps/studio/.github/eslint-rule-baselines.json |
| 68 | + git commit --message "chore: decrease ESLint ratchet baselines" |
| 69 | + git push --force origin "$BRANCH" |
| 70 | +
|
| 71 | + pr_url=$(gh pr list --state open --head "$BRANCH" --json url --jq '.[0].url // ""' 2>/dev/null || echo "") |
| 72 | + if [ -z "$pr_url" ]; then |
| 73 | + gh pr create \ |
| 74 | + --title "[bot] Decrease ESLint ratchet baselines" \ |
| 75 | + --body "Automated weekly decrease of ESLint ratchet baselines." \ |
| 76 | + --base "$DEFAULT_BRANCH" \ |
| 77 | + --head "$BRANCH" |
| 78 | + else |
| 79 | + gh pr comment "$pr_url" --body "Updated ESLint ratchet baselines with the latest weekly decreases." |
| 80 | + fi |
0 commit comments