]> Sergey Matveev's repositories - btrtrc.git/commitdiff
go CI: Use common action and parallel jobs
authorMatt Joiner <anacrolix@gmail.com>
Thu, 10 Feb 2022 01:33:04 +0000 (12:33 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 10 Feb 2022 01:33:04 +0000 (12:33 +1100)
.github/actions/go-common/action.yml [new file with mode: 0644]
.github/workflows/go.yml

diff --git a/.github/actions/go-common/action.yml b/.github/actions/go-common/action.yml
new file mode 100644 (file)
index 0000000..5dfb32b
--- /dev/null
@@ -0,0 +1,25 @@
+name: 'Common Go'
+description: 'Checks out, and handles Go setup and caching'
+runs:
+  using: "composite"
+  steps:
+    - name: Set up Go
+      uses: actions/setup-go@v2
+      with:
+        go-version: ${{ matrix.go-version }}
+    - uses: actions/cache@v2
+      with:
+        path: |
+          ~/.cache/go-build
+          ~/go/pkg/mod
+        # The OS defines the directories to use, then this is specific to go. The go version could
+        # affect the dependencies. The job can affect what is actually downloaded, and provides
+        # collision resistance. Finally, the hash of the go.sum files ensures a new cache is created
+        # when the dependencies change. Note if this were just a mod cache, we might do this based
+        # on time or something.
+        key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
+        restore-keys: |
+          ${{ runner.os }}-go-${{ matrix.go-version }}-${{ github.job }}-
+          ${{ runner.os }}-go-${{ matrix.go-version }}-
+          ${{ runner.os }}-go-
+          
index 6c9f912e169dae069f6b9e33fe2d5663c3ec5686..1d7bbd55d02ca9bc9cfc366585eb4c4d87f39272 100644 (file)
@@ -4,8 +4,7 @@ on: [push, pull_request]
 
 jobs:
 
-  build:
-    timeout-minutes: 30
+  test:
     runs-on: ubuntu-latest
     strategy:
       matrix:
@@ -13,28 +12,64 @@ jobs:
       fail-fast: false
     steps:
     - uses: actions/checkout@v2
+    - uses: ./.github/actions/go-common
+    - run: go test -race -count 2 ./...
 
-    - name: Set up Go
-      uses: actions/setup-go@v2
-      with:
-        go-version: ${{ matrix.go-version }}
-
-    - name: Test
-      run: go test -race -count 2 ./...
-
-    - name: Test Benchmarks
-      run: go test -race -run @ -bench . -benchtime 2x ./...
+  test-benchmarks:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        go-version: [ '1.17' ]
+      fail-fast: false
+    steps:
+    - uses: actions/checkout@v2
+    - uses: ./.github/actions/go-common
+    - run: go test -race -run @ -bench . -benchtime 2x ./...
 
-    - name: Bench
-      run: go test -run @ -bench . ./...
+  bench:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        go-version: [ '1.17' ]
+      fail-fast: false
+    steps:
+    - uses: actions/checkout@v2
+    - uses: ./.github/actions/go-common
+    - run: go test -run @ -bench . ./...
 
-    - name: Test on 386
-      run: GOARCH=386 go test ./... -bench .
-      continue-on-error: true
+  test-386:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        go-version: [ '1.16', '1.17' ]
+      fail-fast: false
+    steps:
+    - uses: actions/checkout@v2
+    - uses: ./.github/actions/go-common
+    - run: GOARCH=386 go test ./...
+    - run: GOARCH=386 go test ./... -run @ -bench .
 
+  build-wasm:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        go-version: [ '1.16', '1.17' ]
+      fail-fast: false
+    steps:
+    - uses: actions/checkout@v2
+    - uses: ./.github/actions/go-common
     - name: Some packages compile for WebAssembly
-      run: GOOS=js GOARCH=wasm go build . ./storage ./tracker/...
+      run: GOOS=js GOARCH=wasm go build -v . ./storage ./tracker/...
 
+  torrentfs:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        go-version: [ '1.17' ]
+      fail-fast: false
+    steps:
+    - uses: actions/checkout@v2
+    - uses: ./.github/actions/go-common
     - name: Install godo
       run: |
         # Need master for cross-compiling fix
@@ -47,4 +82,3 @@ jobs:
     - name: torrentfs end-to-end test
       # Test on 386 for atomic alignment and other bad 64-bit assumptions
       run: GOARCH=386 fs/test.sh
-      timeout-minutes: 10