This is my first try at automating building and testing some code for Linux, MacOS, and Windows (this took the longest to set up). It just builds and runs the tests with make
:
name: Arena Tests
on: [workflow_dispatch, push, pull_request]
jobs:
test_unixy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: make
- name: Test
run: make test
test_windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Setup MSYS2
uses: msys2/setup-msys2/@v2
with:
update: true
install: >-
git
make
gcc
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: make
- name: Test
run: make test
Review Request:
Anything, everything. There's some duplication too, how can I avoid that?
-
\$\begingroup\$ You discovered a bug in your makefile, that it hardcodes "gcc-13". Better that you fix the bug there, than in the source we see in this submission. \$\endgroup\$J_H– J_H2024年04月25日 10:24:20 +00:00Commented Apr 25, 2024 at 10:24
-
\$\begingroup\$ @J_H Fair enough, post updated. \$\endgroup\$Madagascar– Madagascar2024年04月25日 15:08:31 +00:00Commented Apr 25, 2024 at 15:08
1 Answer 1
You could avoid the duplication (and the display of the tests as 2 separate jobs in the GUI), if you united the *nix and Windows jobs, using a single matrix.
The problem that you probably encountered is setting the default shell depending on the os. This is possible though not quite obvious:
jobs:
tests:
runs-on: ${{ matrix.sys.os }}
strategy:
matrix:
sys:
- { os: windows-latest, shell: 'msys2 {0}' }
- { os: ubuntu-latest, shell: bash }
- { os: macos-latest, shell: bash }
defaults:
run:
shell: ${{ matrix.sys.shell }}
steps:
- name: Setup MSYS2
if: ${{ matrix.sys.os == "windows-latest" }}
uses: msys2/setup-msys2/@v2
with:
update: true
install: >-
git
make
gcc
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: make
- name: Test
run: make test
Apart from that, the workflow is simple enough, and I don't see any need for improvement.