Skip to content

Fix tests running Windows #12

Fix tests running Windows

Fix tests running Windows #12

Workflow file for this run

name: Build and Test
on: [pull_request]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SYSL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SYSL_PLANTUML: http://www.plantuml.com/plantuml
GOPROXY: ${{ vars.GOPROXY }}
NPM_CONFIG_REGISTRY: ${{ vars.NPM_CONFIG_REGISTRY }}
DOCKER_BUILD_ARGS: ${{ vars.DOCKER_BUILD_ARGS }}
jobs:
build-and-test:
name: Build and Test
strategy:
matrix:
os: ${{ vars.BUILD_AND_TEST_OS_MATRIX && fromJSON(vars.BUILD_AND_TEST_OS_MATRIX) || fromJSON('[ "ubuntu-latest", "macOS-latest", "windows-latest" ]') }}
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
cache: false
- name: Set up Node
if: runner.os != 'Windows'
uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/go/bin
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Needed to get the head of the branch for pull request events
fetch-depth: 0
- name: Ensure no tests are using Jest's 'test.only()'
if: runner.os == 'Linux'
run: find ts/src -type f -name '*.test.ts' | (! xargs grep 'test\.only\(')
- name: Generate intermediate files
run: make generate
- name: Run unit tests
if: runner.os != 'Windows'
run: make test
- name: Run unit tests (Windows)
if: runner.os == 'Windows'
run: .\scripts\test-with-coverage-windows.bat
- name: Set GOVERSION environment variable
run: echo "GOVERSION=$(go version | awk '{print $3, $4;}')" >> $GITHUB_ENV
- name: Build sysl binary
if: runner.os != 'Windows'
run: make build
# According to https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
# Ubuntu: sysl_linux_amd64:
# macOS Catalina: sysl_darwin_amd64
- name: Install sysl
if: runner.os != 'Windows'
run: |
mkdir bin && \
cp dist/sysl bin/sysl
- name: Test installed
if: runner.os != 'Windows'
run: ./scripts/test-gosysl.sh
env:
GOPATH: .
- name: Build sysl binary (Windows)
if: runner.os == 'Windows'
run: make build-windows
# sysl_windows_amd64: according to https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
# Windows Server 2019 supports 64-bit applications
- name: Install sysl (Windows)
if: runner.os == 'Windows'
run: md .\bin; copy .\dist\sysl.exe .\bin\sysl.exe
- name: Test installed (Windows)
if: runner.os == 'Windows'
run: .\scripts\test-gosysl.bat
- name: Install TypeScript deps
if: runner.os != 'Windows'
run: |
# install yarn if needed
npm i -g yarn
# switch registry in lock file
if [ -n "${{ env.NPM_CONFIG_REGISTRY }}" ]; then
sed -i'.bak' 's#https://registry.npmjs.org#${{ env.NPM_CONFIG_REGISTRY }}#' yarn.lock
rm yarn.lock.bak
fi
yarn install --frozen-lockfile
working-directory: ts
- name: Test TypeScript
if: runner.os != 'Windows'
run: yarn test
working-directory: ts
env:
SYSL_PATH: ../bin/sysl
build-docker:
name: Builds the sysl docker image
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
cache: false
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate intermediate files
run: make generate
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/anzbank/sysl
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{raw}}
type=sha,prefix=,format=long
labels: |
org.opencontainers.image.url=https://sysl.io
- name: Build docker image
uses: docker/build-push-action@v6
with:
context: .
pull: true
load: true
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: ${{ env.DOCKER_BUILD_ARGS }}
Lint:
name: Lint
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Tidy
run: go mod tidy
- name: Generate intermediate files
run: make -B generate
- name: Run golangci-lint
run: make lint-docker
- name: Check tidy
run: make check-clean
- name: Validate goreleaser config
run: |
go run github.com/goreleaser/goreleaser/v2@v2.1.0 check -f .goreleaser.yml