mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-28 13:57:52 +08:00
- define COVERPKG_EXCLUDE and UNIT_EXCLUDE as documented variables
- use grep -vE with single regex instead of multiple grep -v calls
- add mkdir -p before rm to ensure directories exist
- add DEPS_GO dependency to test_cli target
- make CLI test timeout configurable via TEST_CLI_TIMEOUT (default 10m)
- fix test_examples cleanup on failure using subshell
- reduce GetClosestPeers test wait time from 3m to 2m
- rename artifacts to match job names: unit-tests-{junit,html}, cli-tests-{junit,html}
- update cli-tests upload-artifact from v5 to v6
171 lines
5.5 KiB
YAML
171 lines
5.5 KiB
YAML
name: Go Test
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**/*.md'
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# Unit tests with coverage collection (uploaded to Codecov)
|
|
unit-tests:
|
|
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
|
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "2xlarge"]' || '"ubuntu-latest"') }}
|
|
timeout-minutes: 15
|
|
env:
|
|
GOTRACEBACK: single # reduce noise on test timeout panics
|
|
TEST_DOCKER: 0
|
|
TEST_FUSE: 0
|
|
TEST_VERBOSE: 1
|
|
GIT_PAGER: cat
|
|
IPFS_CHECK_RCMGR_DEFAULTS: 1
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- name: Check out Kubo
|
|
uses: actions/checkout@v6
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
- name: Install missing tools
|
|
run: sudo apt update && sudo apt install -y zsh
|
|
- name: Run unit tests
|
|
run: |
|
|
make test_unit &&
|
|
[[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
|
if: failure() || success()
|
|
with:
|
|
name: unittests
|
|
files: coverage/unit_tests.coverprofile
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: false
|
|
- name: Create a proper JUnit XML report
|
|
uses: ipdxco/gotest-json-to-junit-xml@v1
|
|
with:
|
|
input: test/unit/gotest.json
|
|
output: test/unit/gotest.junit.xml
|
|
if: failure() || success()
|
|
- name: Archive the JUnit XML report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: unit-tests-junit
|
|
path: test/unit/gotest.junit.xml
|
|
if: failure() || success()
|
|
- name: Create a HTML report
|
|
uses: ipdxco/junit-xml-to-html@v1
|
|
with:
|
|
mode: no-frames
|
|
input: test/unit/gotest.junit.xml
|
|
output: test/unit/gotest.html
|
|
if: failure() || success()
|
|
- name: Archive the HTML report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: unit-tests-html
|
|
path: test/unit/gotest.html
|
|
if: failure() || success()
|
|
- name: Create a Markdown report
|
|
uses: ipdxco/junit-xml-to-html@v1
|
|
with:
|
|
mode: summary
|
|
input: test/unit/gotest.junit.xml
|
|
output: test/unit/gotest.md
|
|
if: failure() || success()
|
|
- name: Set the summary
|
|
run: cat test/unit/gotest.md >> $GITHUB_STEP_SUMMARY
|
|
if: failure() || success()
|
|
|
|
# End-to-end integration/regression tests from test/cli
|
|
# (Go-based replacement for legacy test/sharness shell scripts)
|
|
cli-tests:
|
|
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
|
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "2xlarge"]' || '"ubuntu-latest"') }}
|
|
timeout-minutes: 15
|
|
env:
|
|
GOTRACEBACK: single # reduce noise on test timeout panics
|
|
TEST_VERBOSE: 1
|
|
GIT_PAGER: cat
|
|
IPFS_CHECK_RCMGR_DEFAULTS: 1
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- name: Check out Kubo
|
|
uses: actions/checkout@v6
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
- name: Install missing tools
|
|
run: sudo apt update && sudo apt install -y zsh
|
|
- name: Run CLI tests
|
|
env:
|
|
IPFS_PATH: ${{ runner.temp }}/ipfs-test
|
|
run: make test_cli
|
|
- name: Create JUnit XML report
|
|
uses: ipdxco/gotest-json-to-junit-xml@v1
|
|
with:
|
|
input: test/cli/cli-tests.json
|
|
output: test/cli/cli-tests.junit.xml
|
|
if: failure() || success()
|
|
- name: Archive JUnit XML report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: cli-tests-junit
|
|
path: test/cli/cli-tests.junit.xml
|
|
if: failure() || success()
|
|
- name: Create HTML report
|
|
uses: ipdxco/junit-xml-to-html@v1
|
|
with:
|
|
mode: no-frames
|
|
input: test/cli/cli-tests.junit.xml
|
|
output: test/cli/cli-tests.html
|
|
if: failure() || success()
|
|
- name: Archive HTML report
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: cli-tests-html
|
|
path: test/cli/cli-tests.html
|
|
if: failure() || success()
|
|
- name: Create Markdown report
|
|
uses: ipdxco/junit-xml-to-html@v1
|
|
with:
|
|
mode: summary
|
|
input: test/cli/cli-tests.junit.xml
|
|
output: test/cli/cli-tests.md
|
|
if: failure() || success()
|
|
- name: Set summary
|
|
run: cat test/cli/cli-tests.md >> $GITHUB_STEP_SUMMARY
|
|
if: failure() || success()
|
|
|
|
# Example tests (kubo-as-a-library)
|
|
example-tests:
|
|
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
|
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "2xlarge"]' || '"ubuntu-latest"') }}
|
|
timeout-minutes: 5
|
|
env:
|
|
GOTRACEBACK: single
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- name: Check out Kubo
|
|
uses: actions/checkout@v6
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: 'go.mod'
|
|
- name: Run example tests
|
|
run: make test_examples
|