kubo/.github/workflows/sharness.yml
Gus Eggert a24cfb89a5
test: port remote pinning tests to Go (#9720)
This also means that rb-pinning-service-api is no longer required for
running remote pinning tests. This alone saves at least 3 minutes in
test runtime in CI because we don't need to checkout the repo, build
the Docker image, run it, etc.

Instead this implements a simple pinning service in Go that the test
runs in-process, with a callback that can be used to control the async
behavior of the pinning service (e.g. simulate work happening
asynchronously like transitioning from "queued" -> "pinning" ->
"pinned").

This also adds an environment variable to Kubo to control the MFS
remote pin polling interval, so that we don't have to wait 30 seconds
in the test for MFS changes to be repinned. This is purely for tests
so I don't think we should document this.

This entire test suite runs in around 2.5 sec on my laptop, compared to
the existing 3+ minutes in CI.
2023-03-30 07:46:35 -04:00

124 lines
4.8 KiB
YAML

name: Sharness
on:
workflow_dispatch:
pull_request:
push:
branches:
- 'master'
jobs:
sharness-runner:
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
uses: ipfs/kubo/.github/workflows/runner.yml@master
sharness-test:
needs: [sharness-runner]
runs-on: ${{ fromJSON(needs.sharness-runner.outputs.config).labels }}
timeout-minutes: 20
defaults:
run:
shell: bash
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.1
- name: Checkout Kubo
uses: actions/checkout@v3
with:
path: kubo
- name: Install missing tools
run: sudo apt install -y socat net-tools fish libxml2-utils
- name: Restore Go Cache
uses: protocol/cache-go-action@v1
with:
name: ${{ github.job }}
- uses: actions/cache@v3
with:
path: test/sharness/lib/dependencies
key: ${{ runner.os }}-test-generate-junit-html-${{ hashFiles('test/sharness/lib/test-generate-junit-html.sh') }}
- name: Run Sharness tests
run: |
make -O -j "$PARALLEL" \
test_sharness \
coverage/sharness_tests.coverprofile \
test/sharness/test-results/sharness.xml
working-directory: kubo
env:
TEST_NO_DOCKER: 0
TEST_NO_PLUGIN: 1
TEST_NO_FUSE: 1
TEST_VERBOSE: 1
TEST_JUNIT: 1
TEST_EXPENSIVE: 1
IPFS_CHECK_RCMGR_DEFAULTS: 1
CONTINUE_ON_S_FAILURE: 1
PARALLEL: ${{ fromJSON(needs.sharness-runner.outputs.config).parallel }}
- name: Upload coverage report
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
if: failure() || success()
with:
name: sharness
files: kubo/coverage/sharness_tests.coverprofile
- name: Aggregate results
run: find kubo/test/sharness/test-results -name 't*-*.sh.*.counts' | kubo/test/sharness/lib/sharness/aggregate-results.sh > kubo/test/sharness/test-results/summary.txt
- name: 👉️ If this step failed, go to «Summary» (top left) → «HTML Report» → inspect the «Failures» column
run: |
cat kubo/test/sharness/test-results/summary.txt &&
grep 'failed\s*0' kubo/test/sharness/test-results/summary.txt
- name: Add aggregate results to the summary
if: failure() || success()
run: |
echo "# Summary" >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
cat kubo/test/sharness/test-results/summary.txt >> $GITHUB_STEP_SUMMARY
- name: Generate one-page HTML report
uses: pl-strflt/junit-xml-to-html@v1
if: failure() || success()
with:
mode: no-frames
input: kubo/test/sharness/test-results/sharness.xml
output: kubo/test/sharness/test-results/sharness.html
- name: Upload one-page HTML report to S3
id: one-page
uses: pl-strflt/tf-aws-gh-runner/.github/actions/upload-artifact@main
if: fromJSON(needs.sharness-runner.outputs.config).aws && (failure() || success())
with:
source: kubo/test/sharness/test-results/sharness.html
destination: sharness.html
- name: Upload one-page HTML report
if: (! fromJSON(needs.sharness-runner.outputs.config).aws) && (failure() || success())
uses: actions/upload-artifact@v3
with:
name: sharness.html
path: kubo/test/sharness/test-results/sharness.html
- name: Generate full HTML report
uses: pl-strflt/junit-xml-to-html@v1
if: failure() || success()
with:
mode: frames
input: kubo/test/sharness/test-results/sharness.xml
output: kubo/test/sharness/test-results/sharness-html
- name: Upload full HTML report to S3
id: full
uses: pl-strflt/tf-aws-gh-runner/.github/actions/upload-artifact@main
if: fromJSON(needs.sharness-runner.outputs.config).aws && (failure() || success())
with:
source: kubo/test/sharness/test-results/sharness-html
destination: sharness-html/
- name: Upload full HTML report
if: (! fromJSON(needs.sharness-runner.outputs.config).aws) && (failure() || success())
uses: actions/upload-artifact@v3
with:
name: sharness-html
path: kubo/test/sharness/test-results/sharness-html
- name: Add S3 links to the summary
if: fromJSON(needs.sharness-runner.outputs.config).aws && (failure() || success())
run: echo "$MD" >> $GITHUB_STEP_SUMMARY
env:
MD: |
# HTML Reports
- View the [one page HTML report](${{ steps.one-page.outputs.url }})
- View the [full HTML report](${{ steps.full.outputs.url }}index.html)