| 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 |
branches: |
| 21 |
- master |
| 22 |
pull_request: |
| 23 |
branches: |
| 24 |
- master |
| 25 |
|
| 26 |
jobs: |
| 27 |
build: |
| 28 |
strategy: |
| 29 |
matrix: |
| 30 |
go: ['1.23', '1.24', '1.25'] |
| 31 |
name: Build (Go ${{ matrix.go }}) |
| 32 |
runs-on: ubuntu-latest |
| 33 |
steps: |
| 34 |
- uses: actions/checkout@v4 |
| 35 |
- uses: actions/setup-go@v2 |
| 36 |
with: |
| 37 |
go-version: ${{ matrix.go }} |
| 38 |
- name: Install dependencies |
| 39 |
run: | |
| 40 |
sudo apt-get update |
| 41 |
sudo apt-get install -y libpam0g-dev |
| 42 |
- name: Build |
| 43 |
run: make |
| 44 |
|
| 45 |
build-32bit: |
| 46 |
name: Build (32-bit) |
| 47 |
runs-on: ubuntu-latest |
| 48 |
steps: |
| 49 |
- uses: actions/checkout@v4 |
| 50 |
- uses: actions/setup-go@v2 |
| 51 |
with: |
| 52 |
go-version: '1.25' |
| 53 |
- name: Install dependencies |
| 54 |
run: | |
| 55 |
sudo dpkg --add-architecture i386 |
| 56 |
sudo apt-get update |
| 57 |
sudo apt-get install -y libpam0g-dev:i386 gcc-multilib |
| 58 |
- name: Build |
| 59 |
run: CGO_ENABLED=1 GOARCH=386 make |
| 60 |
|
| 61 |
run-integration-tests: |
| 62 |
name: Run integration tests |
| 63 |
runs-on: ubuntu-latest |
| 64 |
steps: |
| 65 |
- uses: actions/checkout@v4 |
| 66 |
- uses: actions/setup-go@v2 |
| 67 |
with: |
| 68 |
go-version: '1.25' |
| 69 |
- name: Install dependencies |
| 70 |
run: | |
| 71 |
sudo apt-get update |
| 72 |
sudo apt-get install -y libpam0g-dev e2fsprogs keyutils |
| 73 |
- name: Run integration tests |
| 74 |
run: | |
| 75 |
make test-setup |
| 76 |
keyctl link @u @s |
| 77 |
make test |
| 78 |
make test-teardown |
| 79 |
|
| 80 |
# This isn't working currently because qemu user-mode emulation doesn't |
| 81 |
# support passing through the keyctl() system call and the fscrypt ioctls. |
| 82 |
# Hopefully GitHub Actions will natively support other architectures soon... |
| 83 |
# |
| 84 |
# run-integration-tests-other-arch: |
| 85 |
# name: Run integration tests (${{ matrix.arch }}) |
| 86 |
# strategy: |
| 87 |
# matrix: |
| 88 |
# arch: [armv7, aarch64, ppc64le] |
| 89 |
# runs-on: ubuntu-latest |
| 90 |
# steps: |
| 91 |
# - uses: actions/checkout@v4 |
| 92 |
# - uses: uraimo/[email protected] |
| 93 |
# with: |
| 94 |
# arch: ${{ matrix.arch }} |
| 95 |
# distro: buster |
| 96 |
# githubToken: ${{ github.token }} |
| 97 |
# # Needed for 'make test-setup' to mount the test filesystem. |
| 98 |
# dockerRunArgs: --privileged |
| 99 |
# install: | |
| 100 |
# apt-get update |
| 101 |
# apt-get install -y build-essential git sudo golang-go \ |
| 102 |
# libpam0g-dev e2fsprogs keyutils |
| 103 |
# run: | |
| 104 |
# make test-setup |
| 105 |
# keyctl link @u @s |
| 106 |
# make test |
| 107 |
# make test-teardown |
| 108 |
|
| 109 |
test-cgroup-integration: |
| 110 |
name: Test cgroup integration |
| 111 |
runs-on: ubuntu-latest |
| 112 |
steps: |
| 113 |
- uses: actions/checkout@v4 |
| 114 |
- uses: actions/setup-go@v2 |
| 115 |
with: |
| 116 |
go-version: '1.25' |
| 117 |
- name: Build test binary |
| 118 |
run: go test -c -o cgroup.test ./cgroup/ |
| 119 |
- name: Run cgroup integration test |
| 120 |
run: | |
| 121 |
docker run --rm \ |
| 122 |
--cpus=0.5 --memory=128m \ |
| 123 |
-e CGROUP_EXPECTED_CPU_QUOTA=0.5 \ |
| 124 |
-e CGROUP_EXPECTED_MEMORY_LIMIT=134217728 \ |
| 125 |
-v "$PWD/cgroup.test":/cgroup.test:ro \ |
| 126 |
debian:bookworm-slim \ |
| 127 |
/cgroup.test -test.run TestIntegrationCgroupLimits -test.v |
| 128 |
|
| 129 |
run-cli-tests: |
| 130 |
name: Run command-line interface tests |
| 131 |
runs-on: ubuntu-latest |
| 132 |
steps: |
| 133 |
- uses: actions/checkout@v4 |
| 134 |
- uses: actions/setup-go@v2 |
| 135 |
with: |
| 136 |
go-version: '1.25' |
| 137 |
- name: Install dependencies |
| 138 |
run: | |
| 139 |
sudo apt-get update |
| 140 |
sudo apt-get install -y libpam0g-dev e2fsprogs expect keyutils |
| 141 |
- name: Run command-line interface tests |
| 142 |
run: make cli-test |
| 143 |
|
| 144 |
generate-format-and-lint: |
| 145 |
name: Generate, format, and lint |
| 146 |
runs-on: ubuntu-latest |
| 147 |
steps: |
| 148 |
- uses: actions/checkout@v4 |
| 149 |
- uses: actions/setup-go@v2 |
| 150 |
with: |
| 151 |
go-version: '1.25' |
| 152 |
- name: Install dependencies |
| 153 |
run: | |
| 154 |
sudo apt-get update |
| 155 |
sudo apt-get install -y libpam0g-dev shellcheck |
| 156 |
make tools |
| 157 |
- name: Generate |
| 158 |
run: make gen && bin/files-changed proto |
| 159 |
- name: Format |
| 160 |
run: make format && bin/files-changed format |
| 161 |
- name: Lint |
| 162 |
run: make lint |