aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 973666ced1d58a46eed535ecb753700b05330e21 (plain)
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
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

name: CI
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  build:
    strategy:
      matrix:
        go: ['1.23', '1.24', '1.25']
    name: Build (Go ${{ matrix.go }})
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go }}
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y libpam0g-dev
    - name: Build
      run: make

  build-32bit:
    name: Build (32-bit)
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v2
      with:
        go-version: '1.25'
    - name: Install dependencies
      run: |
        sudo dpkg --add-architecture i386
        sudo apt-get update
        sudo apt-get install -y libpam0g-dev:i386 gcc-multilib
    - name: Build
      run: CGO_ENABLED=1 GOARCH=386 make

  run-integration-tests:
    name: Run integration tests
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v2
      with:
        go-version: '1.25'
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y libpam0g-dev e2fsprogs keyutils
    - name: Run integration tests
      run: |
        make test-setup
        keyctl link @u @s
        make test
        make test-teardown

  # This isn't working currently because qemu user-mode emulation doesn't
  # support passing through the keyctl() system call and the fscrypt ioctls.
  # Hopefully GitHub Actions will natively support other architectures soon...
  #
  # run-integration-tests-other-arch:
  #   name: Run integration tests (${{ matrix.arch }})
  #   strategy:
  #     matrix:
  #       arch: [armv7, aarch64, ppc64le]
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v4
  #     - uses: uraimo/run-on-arch-action@v2.0.5
  #       with:
  #         arch: ${{ matrix.arch }}
  #         distro: buster
  #         githubToken: ${{ github.token }}
  #         # Needed for 'make test-setup' to mount the test filesystem.
  #         dockerRunArgs: --privileged
  #         install: |
  #           apt-get update
  #           apt-get install -y build-essential git sudo golang-go \
  #                              libpam0g-dev e2fsprogs keyutils
  #         run: |
  #           make test-setup
  #           keyctl link @u @s
  #           make test
  #           make test-teardown

  test-cgroup-integration:
    name: Test cgroup integration
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v2
      with:
        go-version: '1.25'
    - name: Build test binary
      run: go test -c -o cgroup.test ./cgroup/
    - name: Run cgroup integration test
      run: |
        docker run --rm \
          --cpus=0.5 --memory=128m \
          -e CGROUP_EXPECTED_CPU_QUOTA=0.5 \
          -e CGROUP_EXPECTED_MEMORY_LIMIT=134217728 \
          -v "$PWD/cgroup.test":/cgroup.test:ro \
          debian:bookworm-slim \
          /cgroup.test -test.run TestIntegrationCgroupLimits -test.v

  run-cli-tests:
    name: Run command-line interface tests
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v2
      with:
        go-version: '1.25'
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y libpam0g-dev e2fsprogs expect keyutils
    - name: Run command-line interface tests
      run: make cli-test

  generate-format-and-lint:
    name: Generate, format, and lint
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v2
      with:
        go-version: '1.25'
    - name: Install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y libpam0g-dev shellcheck
        make tools
    - name: Generate
      run: make gen && bin/files-changed proto
    - name: Format
      run: make format && bin/files-changed format
    - name: Lint
      run: make lint