1
\$\begingroup\$

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?

asked Apr 24, 2024 at 18:12
\$\endgroup\$
2
  • \$\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\$ Commented Apr 25, 2024 at 10:24
  • \$\begingroup\$ @J_H Fair enough, post updated. \$\endgroup\$ Commented Apr 25, 2024 at 15:08

1 Answer 1

3
\$\begingroup\$

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.

answered Apr 26, 2024 at 16:53
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.