Skip to content

Commit

Permalink
build(task): replace Make and PowerShell with Task
Browse files Browse the repository at this point in the history
Disable fail-fast in BSD CI.
  • Loading branch information
dbohdan committed Dec 3, 2024
1 parent 8a10ec3 commit b113eb2
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 86 deletions.
78 changes: 67 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
name: CI

on: [push, pull_request]

env:
GO_VERSION: '1.21'
TASK_VERSION: 'v3.28'

jobs:
bsd:
runs-on: ${{ matrix.os.host }}
strategy:
fail-fast: false
matrix:
os:
- name: freebsd
architecture: x86-64
version: '14.1'
host: ubuntu-latest

- name: netbsd
architecture: x86-64
version: '10.0'
host: ubuntu-latest

- name: openbsd
architecture: x86-64
version: '7.5'
Expand All @@ -27,36 +39,64 @@ jobs:
version: ${{ matrix.os.version }}
shell: bash
run: |
sudo .github/workflows/install-deps.sh
make test
case "$(uname)" in
FreeBSD)
sudo pkg install -y go
;;
NetBSD)
sudo pkgin -y install go
for bin in /usr/pkg/bin/go1*; do
src=$bin
done
sudo ln -s "$src" /usr/pkg/bin/go
;;
OpenBSD)
sudo pkg_add -I go
;;
esac
PATH=$(go env GOPATH)/bin:$PATH
go install 'github.com/go-task/task/v3/cmd/task@${{ env.TASK_VERSION }}'
task
linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Task
run: |
sudo .github/workflows/install-deps.sh
go install github.com/go-task/task/v3/cmd/task@"$TASK_VERSION"
- name: Test
- name: Build and test
run: |
make test
task
mac:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Task
run: |
.github/workflows/install-deps.sh
go install github.com/go-task/task/v3/cmd/task@"$TASK_VERSION"
- name: Build and test
run: |
make test
task
windows:
runs-on: windows-latest
Expand All @@ -67,6 +107,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Test
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Task
run: |
.\test.ps1
go install github.com/go-task/task/v3/cmd/task@$env:TASK_VERSION
- name: Build and test
run: |
task
- name: Upload Windows binary
uses: actions/upload-artifact@v4
with:
name: memsparkline-windows-amd64
path: |
memsparkline.exe
27 changes: 0 additions & 27 deletions .github/workflows/install-deps.sh

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/attic/
/dist/
/.task/

*.bak
*.exe
Expand Down
22 changes: 0 additions & 22 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ go install github.com/dbohdan/memsparkline@latest

- Go 1.21
- OS supported by [gopsutil](https://github.com/shirou/gopsutil)
- POSIX Make for testing
- [Task](https://taskfile.dev/) (go-task) 3.28

## Compatibility and limitations

Expand Down
83 changes: 83 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: '3'

vars:
ext: '{{if eq OS "windows"}}.exe{{end}}'
test_binaries: |
test/sleep
env:
CGO_ENABLED: 0

tasks:
default:
deps:
- all

all:
desc: 'Build and test everything'
deps:
- build
- test

build:
desc: 'Build all components'
deps:
- build_binaries

build_binaries:
desc: 'Build all necessary binaries'
deps:
- build_memsparkline
- build_test_binaries

build_binary:
desc: 'Build a single Go binary'
internal: true
cmds:
- go build -o {{.out | shellQuote}}{{.ext}} {{.src | shellQuote}}

build_memsparkline:
desc: 'Build the memsparkline binary'
cmds:
- task: build_binary
vars:
out: memsparkline
src: main.go
sources:
- main.go
generates:
- memsparkline

build_test_binaries:
desc: 'Build all test binaries'
deps:
- build_test_sleep

build_test_sleep:
cmds:
- task: build_binary
vars:
src: test/sleep.go
out: test/sleep
sources:
- test/sleep.go
generates:
- test/sleep

clean:
desc: 'Clean up generated files and binaries'
cmds:
- rm -f memsparkline
- rm -f {{range .test_binaries | splitLines }}{{. | shellQuote}} {{end}}

release:
desc: 'Prepare a release'
cmds:
- go run script/release.go

test:
desc: 'Run tests'
deps:
- build_binaries
cmds:
- go test
25 changes: 0 additions & 25 deletions test.ps1

This file was deleted.

0 comments on commit b113eb2

Please sign in to comment.