Skip to content

Commit 5d79db0

Browse files
authored
Add matrix demo (#14)
* Add matrix demo * Update README * Cleanup
1 parent 334509a commit 5d79db0

File tree

6 files changed

+48
-10
lines changed

6 files changed

+48
-10
lines changed

.github/workflows/basic.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17-
- name: Setup python
18-
uses: actions/setup-python@v5
17+
- uses: actions/setup-python@v5
1918
with:
2019
python-version-file: .python-version
2120
cache: pip
@@ -31,4 +30,4 @@ jobs:
3130
pip install --requirement requirements.txt
3231
3332
- name: Run test
34-
run: pytest
33+
run: pytest tests/test_basic.py

.github/workflows/basic_uv.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17-
- name: Setup uv
18-
uses: astral-sh/setup-uv@v6
17+
- uses: astral-sh/setup-uv@v6
1918
with:
2019
enable-cache: true
2120

@@ -30,4 +29,4 @@ jobs:
3029
uv tree
3130
3231
- name: Run test
33-
run: uv run -- pytest
32+
run: uv run -- pytest tests/test_basic.py

.github/workflows/cache.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- name: Cache dates
16-
uses: actions/cache@v4
15+
- uses: actions/cache@v4
1716
with:
1817
path: dates.txt
1918
key: dates-${{ github.run_id }}-${{ github.run_attempt }}
@@ -26,6 +25,7 @@ jobs:
2625
if [[ -f "dates.txt" ]]; then
2726
cat dates.txt
2827
else
28+
echo "Initial run. File not found. Creating..."
2929
touch dates.txt
3030
fi
3131

.github/workflows/homebrew.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
- name: Check fortune
1919
run: which fortune || echo "Program not found"
2020

21-
- name: Setup homebrew
22-
uses: Homebrew/actions/setup-homebrew@master
21+
- uses: Homebrew/actions/setup-homebrew@master
2322

2423
- name: Install fortune
2524
run: brew install fortune

.github/workflows/matrix.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Matrix
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: "0 0 1 * *" # Midnight every month (UTC)
7+
workflow_dispatch:
8+
9+
jobs:
10+
run:
11+
name: Run
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
node: [20, 22]
18+
19+
steps:
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node }}
23+
24+
- name: Show node version
25+
run: node --version

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ See the [workflow](.github/workflows/log_annotation.yml).
159159

160160
</details>
161161

162+
## matrix.yml
163+
164+
<details>
165+
166+
<summary>Define a matrix of different job configurations.</summary>
167+
168+
<br/>The matrix strategy lets easily target multiple operating systems or test multiple versions of a language.
169+
170+
- Uses `actions/setup-node`
171+
172+
See the [workflow](.github/workflows/matrix.yml).
173+
174+
</details>
175+
162176
## mise.yml
163177

164178
<details>
@@ -183,12 +197,14 @@ See the [workflow](.github/workflows/mise.yml).
183197
- [GitHub Actions: Caching dependencies to speed up workflows](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows)
184198
- [GitHub Actions: Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows)
185199
- [GitHub Actions: jobs.<job_id>.outputs](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs)
200+
- [GitHub Actions: jobs.<job_id>.strategy.matrix](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)
186201
- [GitHub Actions: Setting an environment variable](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable)
187202
- [GitHub Actions: Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions)
188203
<br/><br/>
189204
- [actions/cache](https://github.com/actions/cache)
190205
- [actions/checkout](https://github.com/actions/checkout)
191206
- [actions/github-script](https://github.com/actions/github-script)
207+
- [actions/setup-node](https://github.com/actions/setup-node)
192208
- [actions/setup-python](https://github.com/actions/setup-python)
193209
- [Homebrew/actions/setup-homebrew](https://github.com/Homebrew/actions/tree/master/setup-homebrew)
194210
- [jdx/mise-action](https://github.com/jdx/mise-action)

0 commit comments

Comments
 (0)