Skip to content

Commit 955e63e

Browse files
committed
ci(examples): add specific testing to make sure the current branch can be used with the examples
1 parent fa7f89d commit 955e63e

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
on: [push, pull_request]
2+
name: Go Test Examples Main
3+
4+
defaults:
5+
working_directory: examples
6+
jobs:
7+
unit:
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ "ubuntu", "windows", "macos" ]
12+
go: [ "1.18.x", "1.19.x" ]
13+
env:
14+
COVERAGES: ""
15+
runs-on: ${{ format('{0}-latest', matrix.os) }}
16+
name: ${{ matrix.os }} (go ${{ matrix.go }})
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
- uses: actions/setup-go@v3
22+
with:
23+
go-version: ${{ matrix.go }}
24+
- name: Go information
25+
run: |
26+
go version
27+
go env
28+
- name: Use msys2 on windows
29+
if: ${{ matrix.os == 'windows' }}
30+
shell: bash
31+
# The executable for msys2 is also called bash.cmd
32+
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#shells
33+
# If we prepend its location to the PATH
34+
# subsequent 'shell: bash' steps will use msys2 instead of gitbash
35+
run: echo "C:/msys64/usr/bin" >> $GITHUB_PATH
36+
- name: Use go mod from current branch
37+
with:
38+
run:
39+
# in addition to the standard tests we want to test the examples against the current branch
40+
# however, that version might be in a fork so we need to replace the dependency
41+
42+
# make sure the examples run against the current version of kubo
43+
go mod edit -replace github.com/ipfs/go-libipfs=./..
44+
go mod tidy
45+
- name: Run tests
46+
uses: protocol/[email protected]
47+
with:
48+
run: go test -v -shuffle=on ./...
49+
- name: Run tests (32 bit)
50+
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
51+
uses: protocol/[email protected]
52+
env:
53+
GOARCH: 386
54+
with:
55+
run: |
56+
export "PATH=${{ env.PATH_386 }}:$PATH"
57+
go test -v -shuffle=on ./...
58+
- name: Run tests with race detector
59+
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
60+
uses: protocol/[email protected]
61+
with:
62+
run: go test -v -race ./...

0 commit comments

Comments
 (0)