| 1 |
# |
| 2 |
# Copyright 2020 Google LLC |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 |
# use this file except in compliance with the License. You may obtain a copy of |
| 6 |
# the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations under |
| 14 |
# the License. |
| 15 |
# |
| 16 |
|
| 17 |
name: CI |
| 18 |
on: |
| 19 |
push: |
| 20 |
tags: |
| 21 |
- v* |
| 22 |
branches: |
| 23 |
- master |
| 24 |
- main |
| 25 |
pull_request: |
| 26 |
|
| 27 |
jobs: |
| 28 |
build: |
| 29 |
strategy: |
| 30 |
matrix: |
| 31 |
go-version: [1.24.x] |
| 32 |
# TODO: Get this working on windows-latest |
| 33 |
os: [ubuntu-latest] |
| 34 |
architecture: [x32, x64] |
| 35 |
include: |
| 36 |
- os: macos-latest |
| 37 |
architecture: arm64 |
| 38 |
go-version: 1.24.x |
| 39 |
- os: macos-14-large |
| 40 |
architecture: x64 |
| 41 |
go-version: 1.24.x |
| 42 |
name: Generate/Build/Test (${{ matrix.os }}, ${{ matrix.architecture }}, Go ${{ matrix.go-version }}) |
| 43 |
runs-on: ${{ matrix.os }} |
| 44 |
steps: |
| 45 |
- uses: actions/checkout@v3 |
| 46 |
with: |
| 47 |
submodules: recursive |
| 48 |
- uses: actions/setup-go@v6 |
| 49 |
with: |
| 50 |
go-version: ${{ matrix.go-version }} |
| 51 |
architecture: ${{ matrix.architecture }} |
| 52 |
- name: Install Protoc |
| 53 |
uses: arduino/setup-protoc@v1 |
| 54 |
with: |
| 55 |
repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 56 |
version: "3.20.1" |
| 57 |
- name: Install protoc-gen-go |
| 58 |
run: go install google.golang.org/protobuf/cmd/[email protected] |
| 59 |
- name: Setup Rust |
| 60 |
uses: dtolnay/rust-toolchain@stable |
| 61 |
- name: Install Build Dependencies (Linux) |
| 62 |
run: sudo apt-get update && sudo apt-get install -y cmake clang pkg-config libssl-dev |
| 63 |
if: runner.os == 'Linux' && matrix.architecture == 'x64' |
| 64 |
- name: Install bindgen-cli |
| 65 |
run: cargo install bindgen-cli |
| 66 |
if: runner.os == 'Linux' && matrix.architecture == 'x64' |
| 67 |
- name: Build KeyManager Rust library |
| 68 |
run: | |
| 69 |
cd keymanager |
| 70 |
cargo build --release |
| 71 |
if: runner.os == 'Linux' && matrix.architecture == 'x64' |
| 72 |
- name: Check Protobuf Generation |
| 73 |
run: | |
| 74 |
go generate ./... ./cmd/... ./launcher/... ./verifier/... |
| 75 |
git diff -G'^[^/]' --exit-code |
| 76 |
- name: Install Linux 64-bit packages |
| 77 |
run: sudo apt-get -y install libssl-dev |
| 78 |
if: runner.os == 'Linux' && matrix.architecture == 'x64' |
| 79 |
- name: Install Linux 32-bit packages |
| 80 |
run: sudo dpkg --add-architecture i386; sudo apt-get update; sudo apt-get -y install libssl-dev:i386 libgcc-s1:i386 gcc-multilib |
| 81 |
if: runner.os == 'Linux' && matrix.architecture == 'x32' |
| 82 |
- name: Install Mac packages |
| 83 |
run: | |
| 84 |
brew install openssl |
| 85 |
if: runner.os == 'macOS' |
| 86 |
- name: Install Windows packages |
| 87 |
run: choco install openssl |
| 88 |
if: runner.os == 'Windows' |
| 89 |
- name: Build all modules except launcher and keymanager |
| 90 |
run: go build -v ./... ./cmd/... ./verifier/... |
| 91 |
- name: Build keymanager module |
| 92 |
run: go build -v ./keymanager/... |
| 93 |
if: runner.os == 'Linux' && matrix.architecture == 'x64' |
| 94 |
- name: Build launcher module |
| 95 |
run: go build -v -ldflags="-extldflags=-Wl,-z,lazy" ./launcher/... |
| 96 |
if: runner.os == 'Linux' |
| 97 |
- name: Run specific tests under root permission |
| 98 |
run: | |
| 99 |
GO_EXECUTABLE_PATH=$(which go) |
| 100 |
sudo $GO_EXECUTABLE_PATH test -v -ldflags="-extldflags=-Wl,-z,lazy" -run "TestFetchImageSignaturesDockerPublic" ./launcher |
| 101 |
if: runner.os == 'Linux' |
| 102 |
- name: Run all tests in launcher to capture potential data race |
| 103 |
run: go test -v -ldflags="-extldflags=-Wl,-z,lazy" -race ./launcher/... |
| 104 |
if: (runner.os == 'Linux') && matrix.architecture == 'x64' |
| 105 |
- name: Test all modules except launcher and keymanager |
| 106 |
run: go test -v ./... ./cmd/... ./verifier/... -skip='TestCacheConcurrentSetGet|TestHwAttestationPass|TestHardwareAttestationPass' |
| 107 |
- name: Test keymanager module |
| 108 |
run: go test -v ./keymanager/... |
| 109 |
if: runner.os == 'Linux' && matrix.architecture == 'x64' |
| 110 |
|
| 111 |
lint: |
| 112 |
strategy: |
| 113 |
matrix: |
| 114 |
go-version: [1.24.x] |
| 115 |
os: [ubuntu-latest] |
| 116 |
dir: ["./", "./cmd", "./launcher", "./keymanager"] |
| 117 |
name: Lint ${{ matrix.dir }} (${{ matrix.os }}, Go ${{ matrix.go-version }}) |
| 118 |
runs-on: ${{ matrix.os }} |
| 119 |
steps: |
| 120 |
- uses: actions/checkout@v3 |
| 121 |
with: |
| 122 |
submodules: recursive |
| 123 |
- uses: actions/setup-go@v2 |
| 124 |
with: |
| 125 |
go-version: ${{ matrix.go-version }} |
| 126 |
- name: Setup Rust |
| 127 |
uses: dtolnay/rust-toolchain@stable |
| 128 |
- name: Install Build Dependencies (Linux) |
| 129 |
run: sudo apt-get update && sudo apt-get install -y cmake clang pkg-config libssl-dev |
| 130 |
- name: Install bindgen-cli |
| 131 |
run: cargo install bindgen-cli |
| 132 |
- name: Build KeyManager Rust library |
| 133 |
run: | |
| 134 |
cd keymanager |
| 135 |
cargo build --release |
| 136 |
- name: Run golangci-lint |
| 137 |
uses: golangci/[email protected] |
| 138 |
with: |
| 139 |
version: latest |
| 140 |
working-directory: ${{ matrix.dir }} |
| 141 |
args: > |
| 142 |
-D errcheck |
| 143 |
-E stylecheck |
| 144 |
-E goimports |
| 145 |
-E misspell |
| 146 |
-E revive |
| 147 |
-E gofmt |
| 148 |
-E goimports |
| 149 |
--exclude-use-default=false |
| 150 |
--max-same-issues=0 |
| 151 |
--max-issues-per-linter=0 |
| 152 |
--timeout 2m |
| 153 |
|
| 154 |
lintc: |
| 155 |
strategy: |
| 156 |
matrix: |
| 157 |
go-version: [1.24.x] |
| 158 |
os: [ubuntu-latest] |
| 159 |
name: Lint CGO (${{ matrix.os }}, Go ${{ matrix.go-version }}) |
| 160 |
runs-on: ${{ matrix.os }} |
| 161 |
steps: |
| 162 |
- uses: actions/checkout@v3 |
| 163 |
with: |
| 164 |
submodules: recursive |
| 165 |
- uses: actions/setup-go@v2 |
| 166 |
with: |
| 167 |
go-version: ${{ matrix.go-version }} |
| 168 |
- name: Setup Rust |
| 169 |
uses: dtolnay/rust-toolchain@stable |
| 170 |
- name: Install Build Dependencies (Linux) |
| 171 |
run: sudo apt-get update && sudo apt-get install -y cmake clang pkg-config libssl-dev |
| 172 |
- name: Install bindgen-cli |
| 173 |
run: cargo install bindgen-cli |
| 174 |
- name: Build KeyManager Rust library |
| 175 |
run: | |
| 176 |
cd keymanager |
| 177 |
cargo build --release |
| 178 |
- name: Check for CGO Warnings (gcc) |
| 179 |
run: CGO_CFLAGS=-Werror CC=gcc go build ./... |
| 180 |
- name: Check for CGO Warnings (clang) |
| 181 |
run: CGO_CFLAGS=-Werror CC=clang go build ./... |