|
| 1 | +name: Remove unnecessary set_option lines |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 4 * * 1" # At 04:00 UTC on Monday. |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + dry_run: |
| 9 | + description: 'If true, only scan and report without modifying files or opening a PR' |
| 10 | + required: false |
| 11 | + default: false |
| 12 | + type: boolean |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Remove unnecessary set_option lines |
| 17 | + runs-on: ubuntu-latest |
| 18 | + if: github.repository == 'leanprover-community/mathlib4' |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 21 | + |
| 22 | + - name: Configure Lean |
| 23 | + uses: leanprover/lean-action@c544e89643240c6b398f14a431bcdc6309e36b3e # v1.4.0 |
| 24 | + with: |
| 25 | + auto-config: false |
| 26 | + use-github-cache: false |
| 27 | + use-mathlib-cache: true |
| 28 | + |
| 29 | + - name: Remove unnecessary set_option lines |
| 30 | + id: rm_set_option |
| 31 | + shell: bash |
| 32 | + run: | |
| 33 | + DRY_RUN_FLAG="" |
| 34 | + if [ "${{ inputs.dry_run }}" = "true" ]; then |
| 35 | + DRY_RUN_FLAG="--dry-run" |
| 36 | + fi |
| 37 | + python3 scripts/rm_set_option.py $DRY_RUN_FLAG |
| 38 | + if git diff --quiet; then |
| 39 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 40 | + else |
| 41 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Generate app token |
| 45 | + id: app-token |
| 46 | + if: steps.rm_set_option.outputs.changed == 'true' |
| 47 | + uses: leanprover-community/mathlib-ci/.github/actions/azure-create-github-app-token@3bb576208589a435eeaeac9b144a1b7c3e948760 |
| 48 | + with: |
| 49 | + app-id: ${{ secrets.MATHLIB_NOLINTS_APP_ID }} |
| 50 | + key-vault-name: ${{ vars.MATHLIB_AZ_KEY_VAULT_NAME }} |
| 51 | + key-name: mathlib-nolints-app-pk |
| 52 | + azure-client-id: ${{ vars.GH_APP_AZURE_CLIENT_ID_PR_WRITERS }} |
| 53 | + azure-tenant-id: ${{ secrets.LPC_AZ_TENANT_ID }} |
| 54 | + |
| 55 | + - name: Create Pull Request |
| 56 | + id: pr |
| 57 | + if: steps.rm_set_option.outputs.changed == 'true' && toJson(inputs.dry_run) != 'true' |
| 58 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 |
| 59 | + with: |
| 60 | + author: "mathlib-nolints[bot] <258989889+mathlib-nolints[bot]@users.noreply.github.com>" |
| 61 | + token: "${{ steps.app-token.outputs.token }}" |
| 62 | + commit-message: "chore: remove unnecessary set_option lines" |
| 63 | + branch: "rm-set-option" |
| 64 | + base: master |
| 65 | + title: "chore: remove unnecessary set_option lines" |
| 66 | + body: | |
| 67 | + I am happy to remove some unnecessary `set_option` lines for you! |
| 68 | +
|
| 69 | + --- |
| 70 | +
|
| 71 | + [workflow run for this PR](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 72 | + # labels: "auto-merge-after-CI" |
| 73 | + |
| 74 | + - name: Send Zulip message (success) |
| 75 | + if: steps.pr.outcome == 'success' |
| 76 | + uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 |
| 77 | + with: |
| 78 | + api-key: ${{ secrets.ZULIP_API_KEY }} |
| 79 | + email: 'github-mathlib4-bot@leanprover.zulipchat.com' |
| 80 | + organization-url: 'https://leanprover.zulipchat.com' |
| 81 | + to: 'nightly-testing' |
| 82 | + type: 'stream' |
| 83 | + topic: 'Mathlib `remove unnecessary set_option lines`' |
| 84 | + content: | |
| 85 | + Please review #${{ steps.pr.outputs.pull-request-number }}, which removes unnecessary set_option lines. |
| 86 | +
|
| 87 | + - name: Send Zulip message (failure) |
| 88 | + if: ${{ toJson(inputs.dry_run) != 'true' && failure() }} |
| 89 | + uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 |
| 90 | + with: |
| 91 | + api-key: ${{ secrets.ZULIP_API_KEY }} |
| 92 | + email: 'github-mathlib4-bot@leanprover.zulipchat.com' |
| 93 | + organization-url: 'https://leanprover.zulipchat.com' |
| 94 | + to: 'nightly-testing' |
| 95 | + type: 'stream' |
| 96 | + topic: 'Mathlib `remove unnecessary set_option lines`' |
| 97 | + content: | |
| 98 | + [`remove unnecessary set_option lines` workflow run failed](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 99 | +
|
| 100 | + triggered by: `${{ github.event_name }}` |
0 commit comments