@@ -217,6 +217,88 @@ jobs:
217217 token : ${{ secrets.CODECOV_TOKEN }}
218218 slug : cyphar/filepath-securejoin
219219
220+ test-libpathrs :
221+ strategy :
222+ fail-fast : false
223+ matrix :
224+ os :
225+ - ubuntu-22.04
226+ - ubuntu-latest
227+ go-version :
228+ - " 1.18"
229+ - " oldstable"
230+ - " stable"
231+ runs-on : ${{ matrix.os }}
232+ steps :
233+ - uses : actions/checkout@v5
234+
235+ - uses : dtolnay/rust-toolchain@stable
236+ - name : find latest libpathrs release
237+ uses : actions/github-script@v8
238+ id : libpathrs-release-tarball
239+ with :
240+ result-encoding : string
241+ script : |-
242+ const latest_release = await github.rest.repos.getLatestRelease({
243+ owner: "cyphar",
244+ repo: "libpathrs",
245+ });
246+ console.log(latest_release);
247+ return latest_release.data.tarball_url;
248+ - name : install libpathrs
249+ run : |-
250+ mkdir -p /tmp/libpathrs
251+ cd /tmp/libpathrs
252+
253+ wget -O latest.tar.gz "${{ steps.libpathrs-release-tarball.outputs.result }}"
254+ tar xvf latest.tar.gz
255+
256+ cd *libpathrs-*/
257+ make release
258+ sudo ./install.sh --libdir=/usr/lib
259+
260+ - uses : actions/setup-go@v6
261+ with :
262+ go-version : ${{ matrix.go-version }}
263+ check-latest : true
264+ - name : mkdir gocoverdir
265+ # We can only use -test.gocoverdir for Go >= 1.20.
266+ if : ${{ matrix.go-version != '1.18' && matrix.go-version != '1.19' }}
267+ run : |
268+ GOCOVERDIR="$(mktemp --tmpdir -d gocoverdir.XXXXXXXX)"
269+ echo "GOCOVERDIR=$GOCOVERDIR" >>"$GITHUB_ENV"
270+ - name : go test
271+ run : |-
272+ pkgs=("./pathrs-lite" "./pathrs-lite/procfs")
273+ if [ -n "${GOCOVERDIR:-}" ]; then
274+ go test -v -timeout=30m -cover -coverpkg=./... "${pkgs[@]}" -args -test.gocoverdir="$GOCOVERDIR"
275+ else
276+ go test -v -timeout=30m -cover -coverpkg=./... -coverprofile codecov-coverage.txt "${pkgs[@]}"
277+ fi
278+ - name : sudo go test
279+ run : |-
280+ pkgs=("./pathrs-lite" "./pathrs-lite/procfs")
281+ if [ -n "${GOCOVERDIR:-}" ]; then
282+ sudo go test -v -timeout=30m -cover -coverpkg=./... "${pkgs[@]}" -args -test.gocoverdir="$GOCOVERDIR"
283+ else
284+ sudo go test -v -timeout=30m -cover -coverpkg=./... -coverprofile codecov-coverage-sudo.txt "${pkgs[@]}"
285+ fi
286+ - name : upload coverage artefact
287+ # We can only use -test.gocoverdir for Go >= 1.20.
288+ if : ${{ matrix.go-version != '1.18' && matrix.go-version != '1.19' }}
289+ uses : actions/upload-artifact@v4
290+ with :
291+ name : coverage-${{ runner.os }}-${{ github.job }}-${{ strategy.job-index }}
292+ path : ${{ env.GOCOVERDIR }}
293+ - name : collate coverage data
294+ if : ${{ env.GOCOVERDIR != '' }}
295+ run : go tool covdata textfmt -i "$GOCOVERDIR" -o "codecov-coverage.txt"
296+ - name : upload coverage to codecov
297+ uses : codecov/codecov-action@v5
298+ with :
299+ token : ${{ secrets.CODECOV_TOKEN }}
300+ slug : cyphar/filepath-securejoin
301+
220302 coverage :
221303 runs-on : ubuntu-latest
222304 needs :
@@ -272,6 +354,7 @@ jobs:
272354 - test-build
273355 - test-windows
274356 - test-unix
357+ - test-libpathrs
275358 - coverage
276359 - codespell
277360 steps :
0 commit comments