Skip to content

Commit fd7ca9c

Browse files
authored
Merge pull request #307 from dafyddj/ci/main-workflow
ci(workflows): add new `main` workflow running `pre-commit`
2 parents b0e28b9 + c7e3955 commit fd7ca9c

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

.github/workflows/main.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
# yamllint disable rule:comments
3+
name: Test & release
4+
5+
'on':
6+
- pull_request
7+
- push
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}',
12+
github.event.repository.default_branch) }}
13+
14+
jobs:
15+
should-run:
16+
name: Prep / Should run
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
outputs:
20+
should-run: ${{ steps.action.outputs.should-run }}
21+
steps:
22+
- id: action
23+
uses:
24+
# yamllint disable-line rule:line-length
25+
techneg-it/should-workflow-run@dcbb88600d59ec2842778ef1e2d41f680f876329 # v1.0.0
26+
pre-commit:
27+
name: Lint / `pre-commit`
28+
needs: should-run
29+
if: fromJSON(needs.should-run.outputs.should-run)
30+
container: techneg/ci-pre-commit:v2.3.3
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 5
33+
steps:
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
- name: Export `CI_CACHE_ID` from container
36+
run: echo "CI_CACHE_ID=$(cat /.ci_cache_id)" >> $GITHUB_ENV
37+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
38+
with:
39+
path: ~/.cache/pre-commit
40+
key: "${{ env.CI_CACHE_ID }}|\
41+
${{ hashFiles('.pre-commit-config.yaml') }}"
42+
- name: Run `pre-commit`
43+
run: |
44+
git config --global --add safe.directory $(pwd)
45+
pre-commit run --all-files --color always --verbose
46+
pre-commit run --color always --hook-stage manual commitlint-ci
47+
results:
48+
name: Release / Collect results
49+
permissions:
50+
checks: read
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 15
53+
steps:
54+
# yamllint disable-line rule:line-length
55+
- uses: poseidon/wait-for-status-checks@899c768d191b56eef585c18f8558da19e1f3e707 # v0.6.0
56+
with:
57+
ignore: Release / Collect results
58+
ignore_pattern: ^GitLab CI
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
- run: echo "::notice ::Workflow success!"

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pre-commit:
8686
- '${PRE_COMMIT_HOME}'
8787
script:
8888
- 'pre-commit run --all-files --color always --verbose'
89+
- 'pre-commit run --color always --hook-stage manual commitlint-ci'
8990

9091
# Use a separate job for `rubocop` other than the one potentially run by `pre-commit`
9192
# - The `pre-commit` check will only be available for formulas that pass the default

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ repos:
100100
- repo: https://github.com/python-jsonschema/check-jsonschema
101101
rev: 0.33.0
102102
hooks:
103+
- id: check-github-workflows
104+
name: Check GitHub workflows with check-jsonschema
105+
args: [--verbose]
103106
- id: check-gitlab-ci
104107
name: Check GitLab CI config with check-jsonschema
105-
args: ["--verbose"]
108+
args: [--verbose]

commitlint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
'header-max-length': [2, 'always', 72],
77
},
88
ignores: [
9-
(commit) => commit.startsWith("chore(deps):")
9+
(commit) => commit.startsWith("chore(deps):"),
10+
(commit) => commit.startsWith("[CI merge]")
1011
],
1112
};

0 commit comments

Comments
 (0)