2023-06-08 14:44:53 +03:00
|
|
|
---
|
|
|
|
name: Go
|
2023-06-08 12:51:42 +03:00
|
|
|
on:
|
|
|
|
pull_request:
|
2023-06-08 14:44:53 +03:00
|
|
|
push:
|
2023-06-08 12:51:42 +03:00
|
|
|
branches:
|
|
|
|
- main
|
2023-08-11 13:27:52 +03:00
|
|
|
- "release-*"
|
2023-06-08 12:51:42 +03:00
|
|
|
|
2024-05-09 14:52:37 +03:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-06-19 11:53:04 +03:00
|
|
|
# Minimal permissions to be inherited by any job that don't declare it's own permissions
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2023-06-08 12:51:42 +03:00
|
|
|
jobs:
|
2024-04-02 08:10:59 +03:00
|
|
|
supportedVersions:
|
|
|
|
name: Fetch supported Go versions
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
supported_versions: ${{ steps.matrix.outputs.supported_versions }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Read supported_go_versions.txt
|
|
|
|
id: matrix
|
|
|
|
run: |
|
2024-04-02 16:10:47 +03:00
|
|
|
versions=$(cat supported_go_versions.txt)
|
2024-04-02 08:10:59 +03:00
|
|
|
matrix="[$(echo "$versions" | sed 's/\(.*\)/"\1"/' | paste -s -d,)]"
|
|
|
|
echo "supported_versions=$matrix" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-06-08 12:51:42 +03:00
|
|
|
test:
|
2023-06-08 14:44:53 +03:00
|
|
|
name: Tests
|
2023-06-08 12:51:42 +03:00
|
|
|
runs-on: ubuntu-latest
|
2024-04-02 08:10:59 +03:00
|
|
|
needs: supportedVersions
|
2023-06-08 12:51:42 +03:00
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-04-02 08:10:59 +03:00
|
|
|
go_version: ${{ fromJSON(needs.supportedVersions.outputs.supported_versions) }}
|
2023-06-08 12:51:42 +03:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2024-01-08 19:45:44 +03:00
|
|
|
uses: actions/checkout@v4.1.1
|
2023-06-08 12:51:42 +03:00
|
|
|
|
|
|
|
- name: Set up Go ${{ matrix.go_version }}
|
2024-07-19 19:13:47 +03:00
|
|
|
uses: actions/setup-go@v5.0.2
|
2023-06-08 12:51:42 +03:00
|
|
|
with:
|
|
|
|
go-version: ${{ matrix.go_version }}
|
|
|
|
|
|
|
|
- name: Cache Go modules
|
|
|
|
id: cache
|
2024-02-01 12:19:29 +03:00
|
|
|
uses: actions/cache@v4
|
2023-06-08 12:51:42 +03:00
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: v1-go${{ matrix.go_version }}
|
|
|
|
|
|
|
|
- name: Run tests and check license
|
|
|
|
run: make check_license test
|
|
|
|
env:
|
|
|
|
CI: true
|
|
|
|
|
|
|
|
- name: Run style and unused
|
|
|
|
if: ${{ matrix.go_version == '1.20' }}
|
2023-06-19 11:53:04 +03:00
|
|
|
run: make style unused
|