-
Notifications
You must be signed in to change notification settings - Fork 3
178 lines (142 loc) · 5.53 KB
/
ci.yml
File metadata and controls
178 lines (142 loc) · 5.53 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: CI
on:
push:
branches:
- main
- release-*
pull_request: {}
workflow_dispatch: {}
permissions:
contents: read
env:
# We can't run a step 'if secrets.FOO != ""' but we can run a step
# 'if env.FOO' != ""', so we copy secrets to env vars for conditional checks.
AWS_USR: ${{ secrets.AWS_USR }}
jobs:
check-diff:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Nix
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
- name: Setup Cachix
uses: cachix/cachix-action@3ba601ff5bbb07c7220846facfa2cd81eeee15a1 # v16
with:
name: crossplane
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Verify Generated Code
run: nix build .#checks.x86_64-linux.generate --print-build-logs
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Nix
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
- name: Setup Cachix
uses: cachix/cachix-action@3ba601ff5bbb07c7220846facfa2cd81eeee15a1 # v16
with:
name: crossplane
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Lint
run: nix build .#checks.x86_64-linux.go-lint --print-build-logs
codeql:
runs-on: ubuntu-24.04
permissions:
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Nix
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
- name: Setup Cachix
uses: cachix/cachix-action@3ba601ff5bbb07c7220846facfa2cd81eeee15a1 # v16
with:
name: crossplane
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Setup Nix Environment
uses: nicknovitski/nix-develop@9be7cfb4b10451d3390a75dc18ad0465bed4932a # v1
- name: Initialize CodeQL
uses: github/codeql-action/init@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4
with:
languages: go
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4
unit-tests:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install Nix
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
- name: Setup Cachix
uses: cachix/cachix-action@3ba601ff5bbb07c7220846facfa2cd81eeee15a1 # v16
with:
name: crossplane
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Run Unit Tests
run: nix build .#checks.x86_64-linux.test --print-build-logs
- name: Publish Unit Test Coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
flags: unittests
file: result/coverage.txt
token: ${{ secrets.CODECOV_TOKEN }}
# Build all artifacts
build-artifacts:
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- name: Cleanup Disk
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: true
dotnet: true
haskell: true
tool-cache: true
swap-storage: false
large-packages: false
docker-images: false
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
- name: Setup Cachix
uses: cachix/cachix-action@3ba601ff5bbb07c7220846facfa2cd81eeee15a1 # v16
with:
name: crossplane
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
# Set buildVersion in flake.nix. The version is an input to the build.
# Pure (sandboxed, reproducible) Nix build inputs can only come from git
# tracked files, so we set it in flake.nix before building.
- name: Set Version
run: |
VERSION=$(git describe --dirty --always --tags | sed 's/-/./2g')
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
sed -i "s|buildVersion = null;|buildVersion = \"$VERSION\";|" flake.nix
- name: Build Artifacts
run: nix build --option warn-dirty false --print-build-logs
- name: Upload Artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: output
path: result/**
- name: Push Artifacts to S3
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-')) && env.AWS_USR != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
AWS_DEFAULT_REGION: us-east-1
run: nix run --option warn-dirty false .#push-artifacts -- "${GITHUB_REF##*/}"
- name: Promote Artifacts to Master Channel
if: github.ref == 'refs/heads/main' && env.AWS_USR != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
AWS_DEFAULT_REGION: us-east-1
run: nix run --option warn-dirty false .#promote-artifacts -- main "$VERSION" master