Skip to content

Commit

Permalink
Add Windows & macOS Acceptance Tests (#875)
Browse files Browse the repository at this point in the history
* add windows tests

* add windows tests

* create a windows makefile

* create a windows makefile

* run windows targets

* run windows targets

* windows compatibility

* windows compatibility

* debug

* windows compatibility

* windows compatibility

* windows compatibility

* windows compatibility

* windows compatibility

* refactor into matrix

* add missing targets

* fix artifacts

* fix mocks

* don't fail fast
  • Loading branch information
osterman authored Dec 20, 2024
1 parent 80058a8 commit 262affa
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 16 deletions.
55 changes: 44 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,22 @@ jobs:
# ensure the code builds...
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux
- os: windows-latest
target: windows
- os: macos-latest
target: macos
runs-on: ${{ matrix.os }}
steps:
- name: Build
run: echo "Building on ${{ matrix.os }}"

- name: Check out code into the Go module directory
uses: actions/checkout@v4

Expand All @@ -42,25 +55,35 @@ jobs:
- name: Build
run: |
make build
make build-${{ matrix.target }}
- name: Version
run: |
make version
make version-${{ matrix.target }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
name: build-artifacts-${{ matrix.target }}
path: |
./build/
# run acceptance tests
test:
name: Acceptance Tests
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux
- os: windows-latest
target: windows
- os: macos-latest
target: macos
timeout-minutes: 15
runs-on: ${{ matrix.os }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand Down Expand Up @@ -133,6 +156,7 @@ jobs:
- /var/run/docker.sock:/var/run/docker.sock

strategy:
fail-fast: false
matrix:
demo-folder:
- demo-localstack
Expand All @@ -142,7 +166,7 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
name: build-artifacts-linux
path: /usr/local/bin

- name: Set execute permissions on atmos
Expand Down Expand Up @@ -195,7 +219,7 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
name: build-artifacts-linux
path: /usr/local/bin

- name: Set execute permissions on atmos
Expand All @@ -222,11 +246,16 @@ jobs:
# run other demo tests
mock:
name: "[mock] ${{ matrix.demo-folder }}"
name: "[mock-${{ matrix.flavor.target}}] ${{ matrix.demo-folder }}"
needs: build
runs-on: ubuntu-latest
runs-on: ${{ matrix.flavor.os }}
strategy:
fail-fast: false
matrix:
flavor:
- { os: ubuntu-latest, target: linux }
- { os: windows-latest, target: windows }
- { os: macos-latest, target: macos }
demo-folder:
- demo-atlantis
# - demo-component-manifest
Expand All @@ -253,7 +282,7 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
name: build-artifacts-${{ matrix.flavor.target }}
path: /usr/local/bin

- name: Set execute permissions on atmos
Expand All @@ -278,6 +307,7 @@ jobs:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
demo-folder:
# - demo-component-manifest
Expand All @@ -297,6 +327,8 @@ jobs:
# - demo-mock-architecture
# - demo-stack-templating
# - demo-multi-cloud
- quick-start-advanced
#- quick-start-simple

timeout-minutes: 20
steps:
Expand Down Expand Up @@ -328,6 +360,7 @@ jobs:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
demo-folder:
- demo-context
Expand Down
35 changes: 30 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
TEST ?= $$(go list ./... | grep -v 'vendor')
# This works because `go list ./...` excludes vendor directories by default in modern versions of Go (1.11+).
# No need for grep or additional filtering.
TEST ?= $$(go list ./...)
SHELL := /bin/bash
#GOOS=darwin
#GOOS=linux
Expand All @@ -17,18 +19,41 @@ lint:
get:
go get

build: get
env $(if $(GOOS),GOOS=$(GOOS)) $(if $(GOARCH),GOARCH=$(GOARCH)) go build -o build/atmos -v -ldflags "-X 'github.com/cloudposse/atmos/pkg/version.Version=${VERSION}'"
build: build-default

version: build
version: version-default

build-linux: GOOS=linux
build-linux: build-default

build-default: get
@echo "Building atmos $(if $(GOOS),GOOS=$(GOOS)) $(if $(GOARCH),GOARCH=$(GOARCH))"
env $(if $(GOOS),GOOS=$(GOOS)) $(if $(GOARCH),GOARCH=$(GOARCH)) go build -o build/atmos -v -ldflags "-X 'github.com/cloudposse/atmos/pkg/version.Version=$(VERSION)'"

build-windows: GOOS=windows
build-windows: get
@echo "Building atmos for $(GOOS) ($(GOARCH))"
go build -o build/atmos.exe -v -ldflags "-X github.com/cloudposse/atmos/pkg/version.Version=$(VERSION)"

build-macos: GOOS=darwin
build-macos: build-default

version-linux: version-default

version-macos: version-default

version-default:
chmod +x ./build/atmos
./build/atmos version

version-windows: build-windows
./build/atmos.exe version

deps:
go mod download

# Run acceptance tests
testacc: get
go test $(TEST) -v $(TESTARGS) -timeout 2m

.PHONY: lint get build deps version testacc
.PHONY: lint get build version build-linux build-windows build-macos deps version-linux version-windows version-macos testacc

0 comments on commit 262affa

Please sign in to comment.