Skip to content

Commit

Permalink
ci: Move manifest job to its own workflow to reduce needless test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 3, 2025
1 parent 55ec4a4 commit 72827a9
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 47 deletions.
48 changes: 1 addition & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- dev
- ci-*
schedule:
- cron: '0 0,3,6,9,12,15,18,21 * * *'
- cron: '0 0 * * *'
workflow_dispatch:

env:
Expand Down Expand Up @@ -232,49 +232,3 @@ jobs:
shell: sh
# TODO: OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in $PATH: unknown
if: (!startsWith(matrix.container, 'opensuse'))

manifest:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
pull-requests: write # for gh pr review --approve
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@stable
- name: Generate Cargo.lock
run: cargo update
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: 'true'
- run: tools/manifest.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Handle diff
id: diff
run: tools/ci/manifest.sh
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main')
- run: git add -N . && git diff --exit-code
- id: create-pull-request
uses: peter-evans/create-pull-request@v7
with:
title: Update manifest
body: |
Auto-generated by CI using [create-pull-request](https://github.com/peter-evans/create-pull-request).
This will be auto-merged when CI has passed because this is an auto-generated PR in a defined format and is usually considered no additional review is required.
branch: update-manifest
token: ${{ secrets.CREATE_PR_TOKEN }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
- name: Enable auto-merge for auto-generated PR
run: gh pr merge --rebase --auto "${PR_NUMBER:?}"
env:
GITHUB_TOKEN: ${{ secrets.CREATE_PR_TOKEN }}
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false' && steps.create-pull-request.outputs.pull-request-operation == 'created'
- name: Approve auto-generated PR for auto-merge
run: gh pr review --approve "${PR_NUMBER:?}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false' && (steps.create-pull-request.outputs.pull-request-operation == 'created' || steps.create-pull-request.outputs.pull-request-operation == 'updated')
79 changes: 79 additions & 0 deletions .github/workflows/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Manifest

permissions:
contents: read

on:
pull_request:
push:
branches:
- main
- dev
- ci-*
schedule:
- cron: '0 0,3,6,9,12,15,18,21 * * *'
workflow_dispatch:

env:
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10

defaults:
run:
shell: bash --noprofile --norc -CeEuxo pipefail {0}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
manifest:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
pull-requests: write # for gh pr review --approve
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@stable
- name: Generate Cargo.lock
run: cargo update
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: 'true'
- run: tools/manifest.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Handle diff
id: diff
run: tools/ci/manifest.sh
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main')
- run: git add -N . && git diff --exit-code
- id: create-pull-request
uses: peter-evans/create-pull-request@v7
with:
title: Update manifest
body: |
Auto-generated by CI using [create-pull-request](https://github.com/peter-evans/create-pull-request).
This will be auto-merged when CI has passed because this is an auto-generated PR in a defined format and is usually considered no additional review is required.
branch: update-manifest
token: ${{ secrets.CREATE_PR_TOKEN }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
- name: Enable auto-merge for auto-generated PR
run: gh pr merge --rebase --auto "${PR_NUMBER:?}"
env:
GITHUB_TOKEN: ${{ secrets.CREATE_PR_TOKEN }}
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false' && steps.create-pull-request.outputs.pull-request-operation == 'created'
- name: Approve auto-generated PR for auto-merge
run: gh pr review --approve "${PR_NUMBER:?}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false' && (steps.create-pull-request.outputs.pull-request-operation == 'created' || steps.create-pull-request.outputs.pull-request-operation == 'updated')

0 comments on commit 72827a9

Please sign in to comment.