|
24 | 24 | runs-on: ubuntu-latest |
25 | 25 | steps: |
26 | 26 | - uses: actions/checkout@v5 |
| 27 | + |
| 28 | + # We need libpathrs so that golangci-lint can typecheck |
| 29 | + # "cyphar.com/go-pathrs" (the package needs to be buildable). |
| 30 | + - uses: dtolnay/rust-toolchain@stable |
| 31 | + - name: find latest libpathrs release |
| 32 | + uses: actions/github-script@v8 |
| 33 | + id: libpathrs-release-tarball |
| 34 | + with: |
| 35 | + result-encoding: string |
| 36 | + script: |- |
| 37 | + const latest_release = await github.rest.repos.getLatestRelease({ |
| 38 | + owner: "cyphar", |
| 39 | + repo: "libpathrs", |
| 40 | + }); |
| 41 | + console.log(latest_release); |
| 42 | + return latest_release.data.tarball_url; |
| 43 | + - name: install libpathrs |
| 44 | + run: |- |
| 45 | + mkdir -p /tmp/libpathrs |
| 46 | + cd /tmp/libpathrs |
| 47 | +
|
| 48 | + wget -O latest.tar.gz "${{ steps.libpathrs-release-tarball.outputs.result }}" |
| 49 | + tar xvf latest.tar.gz |
| 50 | +
|
| 51 | + cd *libpathrs-*/ |
| 52 | + make release |
| 53 | + sudo ./install.sh --libdir=/usr/lib |
| 54 | +
|
27 | 55 | - uses: actions/setup-go@v6 |
28 | 56 | with: |
29 | 57 | go-version: '^1' |
@@ -189,6 +217,88 @@ jobs: |
189 | 217 | token: ${{ secrets.CODECOV_TOKEN }} |
190 | 218 | slug: cyphar/filepath-securejoin |
191 | 219 |
|
| 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 | + |
192 | 302 | coverage: |
193 | 303 | runs-on: ubuntu-latest |
194 | 304 | needs: |
@@ -244,6 +354,7 @@ jobs: |
244 | 354 | - test-build |
245 | 355 | - test-windows |
246 | 356 | - test-unix |
| 357 | + - test-libpathrs |
247 | 358 | - coverage |
248 | 359 | - codespell |
249 | 360 | steps: |
|
0 commit comments