Optimize makefile and support automatic compilation #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Test | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
branches: [ main, master ] | |
jobs: | |
build-matrix: | |
name: Build on ${{ matrix.os }} (${{ matrix.goos }}/${{ matrix.goarch }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
goos: linux | |
goarch: amd64 | |
- os: ubuntu-latest | |
goos: linux | |
goarch: arm64 | |
- os: macos-latest | |
goos: darwin | |
goarch: amd64 | |
- os: macos-latest | |
goos: darwin | |
goarch: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.20' | |
- name: Build | |
run: | | |
make pre_build build_yaml | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o target/chaosblade-${{ matrix.goos }}_${{ matrix.goarch }}/bin/chaos_os main.go | |
test: | |
name: Test on Linux/amd64 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.20' | |
- name: Run tests | |
run: make test |