Skip to content

Commit

Permalink
Run unit tests on macOS in CI
Browse files Browse the repository at this point in the history
Combine the linux and windows unit test jobs into one matrix job and add
a new matrix entry for macOS.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Dec 20, 2024
1 parent d8739ee commit b6a47ef
Showing 1 changed file with 39 additions and 56 deletions.
95 changes: 39 additions & 56 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,90 +116,73 @@ jobs:
name: spdx.json
path: sbom/spdx.json


unittests-k0s-linux-amd64:
name: "Unit tests :: linux-amd64"
runs-on: ubuntu-22.04

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Cache GOCACHE
uses: actions/cache@v4
with:
key: unittests-k0s-linux-amd64-gocache-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
unittests-k0s-linux-amd64-gocache-${{ github.ref_name }}-
build-k0s-linux-amd64-gocache-${{ github.ref_name }}-
path: |
build/cache/go/build
- name: Cache GOMODCACHE
uses: actions/cache@v4
with:
key: unittests-k0s-linux-amd64-gomodcache-${{ hashFiles('go.sum') }}
restore-keys: |
build-k0s-linux-amd64-gomodcache-${{ hashFiles('go.sum') }}
path: |
build/cache/go/mod
- name: Run unit tests
env:
EMBEDDED_BINS_BUILDMODE: none
run: make check-unit

unittests-k0s-windows-amd64:
name: "Unit tests :: windows-amd64"
runs-on: windows-2022
unittests-k0s:
strategy:
matrix:
include:
- name: linux-amd64
runs-on: ubuntu-22.04
- name: windows-amd64
runs-on: windows-2022
target-os: windows
- name: macos-arm64
runs-on: macos-15
target-os: darwin

name: "Unit tests :: ${{ matrix.name }}"
runs-on: "${{ matrix.runs-on }}"

defaults:
run:
shell: bash

env:
EMBEDDED_BINS_BUILDMODE: none

steps:
- name: Check out
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Prepare unit tests
if: matrix.target-os != ''
run: |
make --touch .k0sbuild.docker-image.k0s
cat <<EOF >>"$GITHUB_ENV"
TARGET_OS=${{ matrix.target-os }}
GO=go
GO_ENV=
GOCACHE=${{ env.GITHUB_WORKSPACE }}/build/cache/go/build
GOMODCACHE=${{ env.GITHUB_WORKSPACE }}/build/cache/go/mod
EOF
- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
if: matrix.target-os != ''
with:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Cache GOCACHE
uses: actions/cache@v4
with:
key: unittests-k0s-windows-amd64-gocache-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
unittests-k0s-windows-amd64-gocache-${{ github.ref_name }}-
key: unittests-k0s-${{ matrix.name }}-gocache-${{ github.ref_name }}-${{ github.sha }}
path: |
~\AppData\Local\go-build
build/cache/go/build
- name: Cache GOMODCACHE
uses: actions/cache@v4
with:
key: unittests-k0s-windows-amd64-gomodcache-${{ hashFiles('go.sum') }}
restore-keys: |
build-k0s-windows-amd64-gomodcache-${{ hashFiles('go.sum') }}
key: unittests-k0s-gomodcache-${{ hashFiles('go.sum') }}
path: |
~\go\pkg\mod
build/cache/go/mod
- name: Run unit tests
env:
EMBEDDED_BINS_BUILDMODE: none
TARGET_OS: windows
GO: go
GO_ENV: ''
run: |
make --touch .k0sbuild.docker-image.k0s
make check-unit
run: make check-unit

smoketests:
strategy:
Expand Down

0 comments on commit b6a47ef

Please sign in to comment.