-
Notifications
You must be signed in to change notification settings - Fork 132
137 lines (136 loc) · 4.07 KB
/
ci.yaml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: For each commit and PR
on:
push:
pull_request:
env:
CGO_ENABLED: 0
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
- name: make verify
run: make verify
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
- name: Install nix
uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Fetch Nix Packages
run: nix-shell --run 'true'
- name: Generate
run: GOROOT= nix-shell --run 'make generate'
- name: go clean -testcache
run: go clean -testcache
- name: go test
run: go test -coverprofile=coverage.txt ./... -v
- name: upload codecov
run: bash <(curl -s https://codecov.io/bash)
ci-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install nix
uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Fetch Nix Packages
run: nix-shell --run 'true'
- run: make bin/gofumpt
- run: PATH=$PWD/bin/:$PATH ./ci-checks.sh
validation:
runs-on: ubuntu-latest
needs:
- ci-checks
- test
- verify
steps:
- name: fake
run: echo ":+1:"
crosscompile:
runs-on: ubuntu-latest
needs:
- validation
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.17"
- run: make crosscompile -j$(nproc)
- name: Upload tink-cli binaries
uses: actions/upload-artifact@v2
with:
name: tink-cli
path: cmd/tink-cli/tink-cli-*
- name: Upload tink-server binaries
uses: actions/upload-artifact@v2
with:
name: tink-server
path: cmd/tink-server/tink-server-*
- name: Upload tink-worker binaries
uses: actions/upload-artifact@v2
with:
name: tink-worker
path: cmd/tink-worker/tink-worker-*
docker-images:
runs-on: ubuntu-latest
needs:
- crosscompile
strategy:
matrix:
include:
- repository: quay.io/tinkerbell/tink-cli
binary: tink-cli
- repository: quay.io/tinkerbell/tink
binary: tink-server
- repository: quay.io/tinkerbell/tink-worker
binary: tink-worker
steps:
- name: Docker Image Tag for Sha
id: docker-image-tag
run: |
echo ::set-output name=tags::${{ matrix.repository }}:latest,${{ matrix.repository }}:sha-${GITHUB_SHA::8}
- name: Checkout code
uses: actions/checkout@v2
- name: Login to quay.io
uses: docker/login-action@v1
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Download ${{ matrix.binary }} artifacts
uses: actions/download-artifact@v2
with:
name: ${{ matrix.binary}}
path: cmd/${{ matrix.binary }}
- name: Fix Permissions
run: chmod +x cmd/${{ matrix.binary }}/${{ matrix.binary }}*
- name: ${{ matrix.repository }}
uses: docker/build-push-action@v2
with:
context: cmd/${{ matrix.binary }}/
cache-from: type=registry,ref=${{ matrix.repository }}:latest
push: ${{ startsWith(github.ref, 'refs/heads/main') }}
tags: ${{ steps.docker-image-tag.outputs.tags }}
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64