From 6b950f7e217e30bc596bff7c8fc480381eadf8aa Mon Sep 17 00:00:00 2001 From: Max Williams <8859277+max-rocket-internet@users.noreply.github.com> Date: Wed, 23 Aug 2023 21:05:57 +0200 Subject: [PATCH] Add some CI (#2) * Add some CI * fix "failed to load packages: timed out to load packages" error --------- Co-authored-by: Max Williams --- .github/workflows/fmt.yaml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 29 +++++++++++++++++++++++++++++ .github/workflows/test.yaml | 17 +++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .github/workflows/fmt.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/fmt.yaml b/.github/workflows/fmt.yaml new file mode 100644 index 0000000..dd6db45 --- /dev/null +++ b/.github/workflows/fmt.yaml @@ -0,0 +1,32 @@ +name: golangci-lint + +on: + push: + tags: + - v* + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: false + env: + GO111MODULE: off + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Require: The version of golangci-lint to use. + # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. + # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. + version: v1.54 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..78c0ed6 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: release-build + +on: + release: + types: [created] + +permissions: + contents: write + packages: write + +jobs: + releases-matrix: + name: Release Go Binary + runs-on: ubuntu-latest + strategy: + matrix: + # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 + goos: [linux, windows, darwin] + goarch: ["386", amd64, arm64] + exclude: + - goarch: "386" + goos: darwin + steps: + - uses: actions/checkout@v3 + - uses: wangyoucao577/go-release-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..147b27c --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,17 @@ +name: Go package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + - name: Build + run: go build -v ./... + - name: Test + run: go test -v ./...