|
6 | 6 | - main |
7 | 7 | workflow_call: |
8 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
9 | 13 | permissions: |
10 | 14 | contents: read |
11 | 15 |
|
| 16 | +env: |
| 17 | + PYTHON_VERSION: '3.14' |
| 18 | + CSPELL_VERSION: '8.0.0' |
| 19 | + BLACK_VERSION: '24.10.0' |
| 20 | + PRETTIER_VERSION: '3.3.3' |
| 21 | + COMMITLINT_CLI_VERSION: '20.2.0' |
| 22 | + |
12 | 23 | jobs: |
13 | | - commitlint: |
14 | | - name: Commits |
| 24 | + install-commitlint: |
15 | 25 | runs-on: ubuntu-latest |
16 | | - |
17 | 26 | steps: |
18 | | - - name: Checkout code |
| 27 | + - &checkout-code |
| 28 | + name: Checkout code (shallow) |
19 | 29 | uses: actions/checkout@v5 |
20 | | - with: |
21 | | - fetch-depth: 0 |
22 | | - fetch-tags: true |
23 | 30 |
|
24 | | - - name: Get current year and month for caching |
25 | | - id: date |
26 | | - run: echo "month_year=$(date +'%m-%Y')" >> $GITHUB_OUTPUT |
27 | | - |
28 | | - - name: Cache commitlint tools |
| 31 | + - &cache-commitlint |
| 32 | + name: Cache Commitlint |
29 | 33 | id: cache-commitlint |
30 | 34 | uses: actions/cache@v4 |
31 | 35 | with: |
32 | | - path: ~/.npm-commitlint |
33 | | - key: npm-commitlint-${{ runner.os }}-${{ steps.date.outputs.month_year }}-v1 |
34 | | - restore-keys: | |
35 | | - npm-commitlint-${{ runner.os }}-${{ steps.date.outputs.month_year }}- |
36 | | - npm-commitlint-${{ runner.os }}- |
| 36 | + path: node_modules |
| 37 | + key: v4-commitlint-${{ env.COMMITLINT_CLI_VERSION }} |
37 | 38 |
|
38 | | - - name: Install commitlint and dependencies |
| 39 | + - name: Install Commitlint |
39 | 40 | if: steps.cache-commitlint.outputs.cache-hit != 'true' |
40 | | - run: | |
41 | | - npm config set prefix ~/.npm-commitlint |
42 | | - npm install -g \ |
43 | | - @commitlint/cli \ |
44 | | - @commitlint/config-conventional |
| 41 | + run: npm i -D @commitlint/cli@${{ env.COMMITLINT_CLI_VERSION }} @commitlint/config-conventional |
45 | 42 |
|
46 | | - - name: Add commitlint to PATH |
47 | | - run: echo "$HOME/.npm-commitlint/bin" >> $GITHUB_PATH |
| 43 | + run-commitlint: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: install-commitlint |
| 46 | + steps: |
| 47 | + - name: Checkout code (full) |
| 48 | + uses: actions/checkout@v5 |
| 49 | + with: |
| 50 | + fetch-depth: 0 |
48 | 51 |
|
49 | | - # To avoid having a package.json maintained in this repo, we just pretend to be a Node project during the run |
50 | | - - name: Create symlink for commitlint config |
51 | | - run: | |
52 | | - mkdir -p node_modules/@commitlint |
53 | | - ln -sf ~/.npm-commitlint/lib/node_modules/@commitlint/config-conventional node_modules/@commitlint/config-conventional |
| 52 | + - *cache-commitlint |
54 | 53 |
|
55 | | - - name: Run commitlint on all commits |
56 | | - run: commitlint --from origin/main --to HEAD --verbose |
| 54 | + - name: Run commitlint |
| 55 | + run: | |
| 56 | + git checkout main |
| 57 | + git checkout - |
| 58 | + ./node_modules/.bin/commitlint --from main --to HEAD --verbose |
57 | 59 |
|
58 | | - prettier: |
59 | | - name: Formatting |
| 60 | + install-prettier: |
60 | 61 | runs-on: ubuntu-latest |
61 | | - |
62 | 62 | steps: |
63 | | - - name: Checkout code |
64 | | - uses: actions/checkout@v5 |
65 | | - |
66 | | - - name: Get current year and month for caching |
67 | | - id: date |
68 | | - run: echo "month_year=$(date +'%m-%Y')" >> $GITHUB_OUTPUT |
| 63 | + - *checkout-code |
69 | 64 |
|
70 | | - - name: Cache prettier tools |
| 65 | + - &cache-prettier |
| 66 | + name: Cache Prettier |
71 | 67 | id: cache-prettier |
72 | 68 | uses: actions/cache@v4 |
73 | 69 | with: |
74 | | - path: ~/.npm-prettier |
75 | | - key: npm-prettier-${{ runner.os }}-${{ steps.date.outputs.month_year }}-v1 |
76 | | - restore-keys: | |
77 | | - npm-prettier-${{ runner.os }}-${{ steps.date.outputs.month_year }}- |
78 | | - npm-prettier-${{ runner.os }}- |
| 70 | + path: node_modules |
| 71 | + key: v1-prettier-${{ env.PRETTIER_VERSION }} |
79 | 72 |
|
80 | 73 | - name: Install Prettier |
81 | 74 | if: steps.cache-prettier.outputs.cache-hit != 'true' |
82 | | - run: | |
83 | | - npm config set prefix ~/.npm-prettier |
84 | | - npm install -g prettier |
| 75 | + run: npm i -D prettier@${{ env.PRETTIER_VERSION }} |
85 | 76 |
|
86 | | - - name: Add Prettier to PATH |
87 | | - run: echo "$HOME/.npm-prettier/bin" >> $GITHUB_PATH |
| 77 | + run-prettier: |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: install-prettier |
| 80 | + steps: |
| 81 | + - *checkout-code |
| 82 | + - *cache-prettier |
88 | 83 |
|
89 | 84 | - name: Run Prettier check |
90 | | - run: prettier --check . |
| 85 | + run: ./node_modules/.bin/prettier --check . |
91 | 86 |
|
92 | | - cspell: |
93 | | - name: Spelling |
| 87 | + run-black: |
94 | 88 | runs-on: ubuntu-latest |
95 | | - |
96 | 89 | steps: |
97 | | - - name: Checkout code |
98 | | - uses: actions/checkout@v5 |
| 90 | + - *checkout-code |
99 | 91 |
|
100 | | - - name: Get current year and month for caching |
101 | | - id: date |
102 | | - run: echo "month_year=$(date +'%m-%Y')" >> $GITHUB_OUTPUT |
| 92 | + - name: Setup Python |
| 93 | + uses: actions/setup-python@v6 |
| 94 | + with: |
| 95 | + python-version: '${{ env.PYTHON_VERSION }}' |
| 96 | + |
| 97 | + - name: Cache Black |
| 98 | + uses: actions/cache@v4 |
| 99 | + id: cache-black |
| 100 | + with: |
| 101 | + path: ~/.cache/pip |
| 102 | + key: v1-black-${{ env.BLACK_VERSION }} |
103 | 103 |
|
104 | | - - name: Cache cspell tools |
| 104 | + - name: Install Black |
| 105 | + run: pip install black==${{ env.BLACK_VERSION }} |
| 106 | + |
| 107 | + - name: Run Black check |
| 108 | + run: black --check . |
| 109 | + |
| 110 | + install-cspell: |
| 111 | + runs-on: ubuntu-latest |
| 112 | + steps: |
| 113 | + - *checkout-code |
| 114 | + |
| 115 | + - &cache-cspell |
| 116 | + name: Cache CSpell |
105 | 117 | id: cache-cspell |
106 | 118 | uses: actions/cache@v4 |
107 | 119 | with: |
108 | | - path: ~/.npm-cspell |
109 | | - key: npm-cspell-${{ runner.os }}-${{ steps.date.outputs.month_year }}-v1 |
110 | | - restore-keys: | |
111 | | - npm-cspell-${{ runner.os }}-${{ steps.date.outputs.month_year }}- |
112 | | - npm-cspell-${{ runner.os }}- |
| 120 | + path: node_modules |
| 121 | + key: v1-cspell-${{ env.CSPELL_VERSION }} |
113 | 122 |
|
114 | 123 | - name: Install CSpell |
115 | 124 | if: steps.cache-cspell.outputs.cache-hit != 'true' |
116 | | - run: | |
117 | | - npm config set prefix ~/.npm-cspell |
118 | | - npm install -g cspell |
| 125 | + run: npm i -D cspell |
119 | 126 |
|
120 | | - - name: Add CSpell to PATH |
121 | | - run: echo "$HOME/.npm-cspell/bin" >> $GITHUB_PATH |
| 127 | + run-cspell: |
| 128 | + runs-on: ubuntu-latest |
| 129 | + needs: install-cspell |
| 130 | + steps: |
| 131 | + - *checkout-code |
| 132 | + - *cache-cspell |
122 | 133 |
|
123 | 134 | - name: Run CSpell check |
124 | | - run: cspell |
| 135 | + run: ./node_modules/.bin/cspell |
0 commit comments