|
| 1 | +# Copyright (c) 2025 Joshua Sing <joshua@joshuasing.dev> |
| 2 | +# |
| 3 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | +# of this software and associated documentation files (the "Software"), to deal |
| 5 | +# in the Software without restriction, including without limitation the rights |
| 6 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | +# copies of the Software, and to permit persons to whom the Software is |
| 8 | +# furnished to do so, subject to the following conditions: |
| 9 | +# |
| 10 | +# The above copyright notice and this permission notice shall be included in all |
| 11 | +# copies or substantial portions of the Software. |
| 12 | +# |
| 13 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 | +# SOFTWARE. |
| 20 | + |
| 21 | +# GitHub Actions workflow to build and test. |
| 22 | +name: "Go" |
| 23 | + |
| 24 | +on: |
| 25 | + push: |
| 26 | + branches: [ "main" ] |
| 27 | + pull_request: |
| 28 | + branches: [ "main" ] |
| 29 | + |
| 30 | +env: |
| 31 | + GO_VERSION: "1.24.x" |
| 32 | + |
| 33 | +jobs: |
| 34 | + vulncheck: |
| 35 | + name: "Vulnerability Check" |
| 36 | + runs-on: "ubuntu-latest" |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + steps: |
| 40 | + - name: "Checkout repository" |
| 41 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 42 | + |
| 43 | + - name: "Setup Go ${{ env.GO_VERSION }}" |
| 44 | + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 |
| 45 | + with: |
| 46 | + go-version: "${{ env.GO_VERSION }}" |
| 47 | + cache: true |
| 48 | + check-latest: true |
| 49 | + |
| 50 | + - name: "Install govulncheck" |
| 51 | + run: go install golang.org/x/vuln/cmd/govulncheck@latest |
| 52 | + |
| 53 | + - name: "Run govulncheck" |
| 54 | + run: govulncheck ./... |
| 55 | + |
| 56 | + build: |
| 57 | + name: "Build (${{ matrix.os }})" |
| 58 | + runs-on: "${{ matrix.os }}" |
| 59 | + permissions: |
| 60 | + contents: read |
| 61 | + strategy: |
| 62 | + matrix: |
| 63 | + os: ["ubuntu-latest"] |
| 64 | + steps: |
| 65 | + - name: "Checkout repository" |
| 66 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 67 | + |
| 68 | + - name: "Setup Go ${{ env.GO_VERSION }}" |
| 69 | + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 |
| 70 | + with: |
| 71 | + go-version: "${{ env.GO_VERSION }}" |
| 72 | + cache: true |
| 73 | + check-latest: true |
| 74 | + |
| 75 | + - name: "Download dependencies" |
| 76 | + run: go mod download |
| 77 | + |
| 78 | + - name: "Verify dependencies" |
| 79 | + run: go mod verify |
| 80 | + |
| 81 | + - name: "Build" |
| 82 | + run: go build ./... |
| 83 | + |
| 84 | + - name: "Test" |
| 85 | + run: go test ./... |
| 86 | + |
| 87 | + lint: |
| 88 | + name: "Lint" |
| 89 | + runs-on: "ubuntu-latest" |
| 90 | + permissions: |
| 91 | + contents: read |
| 92 | + steps: |
| 93 | + - name: "Checkout repository" |
| 94 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 95 | + with: |
| 96 | + fetch-depth: 0 |
| 97 | + |
| 98 | + - name: "Setup Go ${{ env.GO_VERSION }}" |
| 99 | + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 |
| 100 | + with: |
| 101 | + go-version: "${{ env.GO_VERSION }}" |
| 102 | + cache: true |
| 103 | + check-latest: true |
| 104 | + |
| 105 | + - name: "Run golangci-lint" |
| 106 | + uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1 |
0 commit comments