Skip to content

Commit

Permalink
ci: add consistency checker
Browse files Browse the repository at this point in the history
Signed-off-by: msclock <msclock@qq.com>
  • Loading branch information
msclock committed Mar 4, 2024
1 parent 8032f3b commit 2554c55
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 2 deletions.
51 changes: 50 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,61 @@ jobs:
with:
commit_message: 'ci: auto fixes from pre-commit'

consistency:
if: ${{ !cancelled() && ! failure() }}
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Git
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- name: Install copier for template rendering using pipx
run: pipx install copier

- name: Generate the project with the default value
run: |
find . -maxdepth 1 ! -name '.' \
! -name 'template' \
! -name 'includes' \
! -name '.git' \
! -name 'copier.yml' \
! -name 'CHANGELOG.md' \
-exec rm -r {} +
copier copy -d repo_host_type=gitlab.com -r HEAD -f . .
rm .copier-answers.yml
copier copy -r HEAD -f . .
rm .copier-answers.yml
- name: List possible inconsistent files
run: git status --porcelain

- name: Test for consistency
run: |
git diff --exit-code || (echo "Inconsistent changes found. Please run 'copier copy -r HEAD -f . .' to fix them." >> $GITHUB_STEP_SUMMARY && exit 1)
pass:
if: always()
needs: [pre-commit, consistency]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

release:
name: release
runs-on: ubuntu-latest
permissions:
contents: write
needs: [pre-commit]
needs: [pass]

steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,61 @@ jobs:
with:
commit_message: 'ci: auto fixes from pre-commit'

consistency:
if: ${{ !cancelled() && ! failure() }}
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Git
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- name: Install copier for template rendering using pipx
run: pipx install copier

- name: Generate the project with the default value
run: |
find . -maxdepth 1 ! -name '.' \
! -name 'template' \
! -name 'includes' \
! -name '.git' \
! -name 'copier.yml' \
! -name 'CHANGELOG.md' \
-exec rm -r {} +
copier copy -d repo_host_type=gitlab.com -r HEAD -f . .
rm .copier-answers.yml
copier copy -r HEAD -f . .
rm .copier-answers.yml
- name: List possible inconsistent files
run: git status --porcelain

- name: Test for consistency
run: |
git diff --exit-code || (echo "Inconsistent changes found. Please run 'copier copy -r HEAD -f . .' to fix them." >> $GITHUB_STEP_SUMMARY && exit 1)
pass:
if: always()
needs: [pre-commit, consistency]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

release:
name: release
runs-on: ubuntu-latest
permissions:
contents: write
needs: [pre-commit]
needs: [pass]

steps:
- name: Checkout
Expand Down

0 comments on commit 2554c55

Please sign in to comment.