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
# SPDX-License-Identifier: MPL-2.0
#
# libpathrs: safe path resolution on Linux
# Copyright (C) 2019-2025 SUSE LLC
# Copyright (C) 2026 Aleksa Sarai <cyphar@cyphar.com>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
on:
push:
branches:
tags:
- 'v*'
pull_request:
branches:
release:
types:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
name: bindings-go
env:
GO_VERSION: 1.27.x
jobs:
lint:
permissions:
contents: read
pull-requests: read
checks: write # to allow the action to annotate code in the pr.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# Build and install libpathrs.so.
- uses: dtolnay/rust-toolchain@stable
- name: build libpathrs
run: make release
- name: install libpathrs
run: sudo ./install.sh --libdir=/usr/lib
# Run golangci-lint.
- uses: golangci/golangci-lint-action@v9
with:
version: v2.13
working-directory: go-pathrs
go-fix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 2
# Build and install libpathrs.so.
- uses: dtolnay/rust-toolchain@stable
- name: build libpathrs
run: make release
- name: install libpathrs
run: sudo ./install.sh --libdir=/usr/lib
# Run go-fix.
- uses: actions/setup-go@v7
with:
go-version: "${{ env.GO_VERSION }}"
- name: run go fix
run: |
cd go-pathrs
go fix ./...
git diff --exit-code
smoke-test:
strategy:
fail-fast: false
matrix:
go-version:
- "1.18"
- "oldstable"
- "stable"
# CGo's behaviour is somewhat compiler-dependent so do smoke tests
# using both clang and gcc to hopefully catch issues earlier.
cc:
- gcc
- clang
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
# Build and install libpathrs.so.
- uses: dtolnay/rust-toolchain@stable
- name: build libpathrs
run: make release
- name: install libpathrs
run: sudo ./install.sh --libdir=/usr/lib
# Setup go.
- name: install go ${{ matrix.go-version }}
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}
check-latest: true
# Run smoke-tests.
# NOTE: CC is only set here (and not for the whole job) so that we don't
# affect how libpathrs itself is built.
- run: make -C examples/go smoke-test
env:
CC: ${{ matrix.cc }}
go-complete:
needs:
- lint
- go-fix
- smoke-test
runs-on: ubuntu-latest
steps:
- run: echo "Go CI jobs completed successfully."