Skip to content

Commit

Permalink
Added test pipeline (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Sep 17, 2023
1 parent ac7402e commit 30875fb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- main

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 'stable'

- name: Map OS to Makefile Target
run: echo "OSKEY=${{ env[matrix.os] }}" >> $GITHUB_ENV
env:
ubuntu-latest: linux
windows-latest: windows
macOS-latest: macos

- name: Test install
run: make test-${{ env.OSKEY }}
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
test-win:
go run . -test -verbose > ./run.ps1
powershell -executionpolicy bypass -File .\run.ps1
test-windows:
@echo "Testing if binary exists in Windows..."
@go run . -test -verbose > ./run.ps1
@powershell -executionpolicy bypass -File ./run.ps1
@powershell -executionpolicy bypass -Command "if (Test-Path $$env:USERPROFILE\instl\instl-demo\instl-demo.exe) { echo 'Binary found in Windows'; exit 0 } else { echo 'Binary not found in Windows'; exit 1 }"

test-linux:
go run . -test -verbose > ./run.sh
cat ./run.sh | bash
@echo "Testing if binary exists in Linux..."
@go run . -test -verbose > ./run.sh
@cat ./run.sh | bash
@(test -f $$HOME/.local/bin/instl-demo && echo "Binary found in Linux" && exit 0) || (echo "Binary not found in Linux" && exit 1)

test-macos:
@echo "Testing if binary exists in macOS..."
@go run . -test -verbose > ./run.sh
@cat ./run.sh | bash
@(test -f $$HOME/.local/bin/instl-demo && echo "Binary found in macOS" && exit 0) || (echo "Binary not found in macOS" && exit 1)

build:
docker build -t marvinjwendt/instl .
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
test := flag.Bool("test", false, "enable test mode; don't start server; print script to stdout")
verbose := flag.Bool("verbose", false, "verbose output for test mode")
owner := flag.String("owner", "installer", "repo owner for test mode")
repo := flag.String("repo", "test-repo", "repo name for test mode")
repo := flag.String("repo", "instl-demo", "repo name for test mode")
flag.Parse()

// Check if test flag is set
Expand Down

0 comments on commit 30875fb

Please sign in to comment.