-
Notifications
You must be signed in to change notification settings - Fork 123
83 lines (70 loc) · 2.27 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
tests:
name: Test code
runs-on: ubuntu-latest
strategy:
matrix:
go: [ 1.21.x, 1.22.x, 1.23.x, tip ]
steps:
- name: Set up Go stable
if: matrix.go != 'tip'
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Set up Go tip
if: matrix.go == 'tip'
run: |
curl -o go.tar.gz -L \
https://github.com/AlekSi/golang-tip/releases/download/tip/master.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go.tar.gz
sudo ln -s /usr/local/go/bin/* /usr/local/bin/
/usr/local/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Checkout to the latest tag
run: |
# Fetch all tags
git fetch --depth=1 --tags
# Get the latest tag
VERS=$(git tag -l | sort -Vr | head -n1)
# Fetch everything to the latest tag
git fetch --shallow-since=$(git log $VERS -1 --format=%at)
if: ${{ github.event_name == 'push' }} # only when built from master
- name: Build project
run: make
- name: Test
run: make test
env:
CGO_ENABLED: 1
- name: Check Docker images
run: |
make image
- name: Check packaging
run: |
go install github.com/goreleaser/nfpm/v2/cmd/[email protected]
make DEVEL=1 nfpm-deb nfpm-rpm
make sum-files
- name: Upload Artifact
if: ${{ matrix.go == 'tip' }} # only upload artifact when built with latest go
id: artifact
uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.go }}
retention-days: 3
path: |
*.deb
*.rpm
sha256sum
md5sum
- name: Push packages to the autobuilds repo
if: ${{ github.event_name == 'push' && matrix.go == 'tip' }} # only when built from master with latest go
run: make DEVEL=1 packagecloud-autobuilds
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}