Skip to content

Commit

Permalink
[ci] Cache go modules and test tools
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-igrychev committed Oct 22, 2019
1 parent 19deae8 commit 38f6f40
Showing 1 changed file with 100 additions and 37 deletions.
137 changes: 100 additions & 37 deletions .github/workflows/main.yml
Expand Up @@ -11,8 +11,54 @@ env:

jobs:

prepare_go_modules_and_test_tools:
name: Prepare go modules and test tools
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:

- name: Set up Go 1.12
uses: actions/setup-go@v1
with:
go-version: 1.12
id: go

- name: Checkout code
uses: actions/checkout@v1

- name: Build
run: |
go get --tags "dfrunmount dfssh" ./...
./scripts/tests/werf_with_coverage.sh
./scripts/ci/crane.sh
./scripts/ci/ginkgo.sh
- name: Pack go modules (ubuntu-latest, macOS-latest)
run: tar -czvf go_modules.tar.gz -C ~/go/pkg/mod .
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

# FIXME: https://github.community/t5/GitHub-Actions/Caching-files-between-GitHub-Action-executions/m-p/30974#M630
- name: Upload go modules artifact (ubuntu-latest, macOS-latest)
uses: actions/upload-artifact@master
with:
name: go_modules_${{ matrix.os }}
path: go_modules.tar.gz
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Upload test tools artifact (ubuntu-latest, macOS-latest)
uses: actions/upload-artifact@master
with:
name: integration_tests_tools
path: bin/tests
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

build:
name: Build
needs: prepare_go_modules_and_test_tools
strategy:
fail-fast: false
matrix:
Expand All @@ -26,6 +72,17 @@ jobs:
go-version: 1.12
id: go

- name: Download go modules artifact (ubuntu-latest, macOS-latest)
uses: actions/download-artifact@master
with:
name: go_modules_${{ matrix.os }}
path: .
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Unpack go modules (ubuntu-latest, macOS-latest)
run: mkdir -p ~/go/pkg/mod && tar -xzvf go_modules.tar.gz -C ~/go/pkg/mod
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Checkout code
uses: actions/checkout@v1

Expand All @@ -34,6 +91,7 @@ jobs:

unit_tests:
name: Unit tests
needs: prepare_go_modules_and_test_tools
strategy:
fail-fast: false
matrix:
Expand All @@ -50,25 +108,36 @@ jobs:
- name: Checkout code
uses: actions/checkout@v1

- name: Prepare environment (!windows)
- name: Download go modules artifact (ubuntu-latest, macOS-latest)
uses: actions/download-artifact@master
with:
name: go_modules_${{ matrix.os }}
path: .
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Unpack go modules (ubuntu-latest, macOS-latest)
run: mkdir -p ~/go/pkg/mod && tar -xzvf go_modules.tar.gz -C ~/go/pkg/mod
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Prepare environment (ubuntu-latest, macOS-latest)
run: |
export WERF_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/unit_tests/${{ matrix.os }}
mkdir -p $WERF_TEST_COVERAGE_DIR
echo ::set-env name=WERF_TEST_COVERAGE_DIR::$WERF_TEST_COVERAGE_DIR
if: matrix.os != 'windows-latest'
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Prepare environment (windows)
- name: Prepare environment (windows-latest)
run: |
SET WERF_TEST_COVERAGE_DIR=%GITHUB_WORKSPACE%\tests_coverage\unit_tests\${{ matrix.os }}
mkdir -p %WERF_TEST_COVERAGE_DIR%
echo ::set-env name=WERF_TEST_COVERAGE_DIR::%WERF_TEST_COVERAGE_DIR%
if: matrix.os == 'windows-latest'

- name: Test (!windows)
- name: Test (ubuntu-latest, macOS-latest)
run: go test -tags "dfrunmount dfssh" -coverpkg=./... -coverprofile=$WERF_TEST_COVERAGE_DIR/coverage.out ./...
if: matrix.os != 'windows-latest'
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'

- name: Test (windows)
- name: Test (windows-latest)
run: go test -tags "dfrunmount dfssh" -coverpkg=./... -coverprofile=%WERF_TEST_COVERAGE_DIR%\coverage.out ./...
if: matrix.os == 'windows-latest'

Expand All @@ -78,8 +147,9 @@ jobs:
name: tests_coverage
path: tests_coverage

prepare_integration_tests_tools:
name: Prepare integration tests tools
integration_tests:
name: Integration tests
needs: prepare_go_modules_and_test_tools
strategy:
fail-fast: false
matrix:
Expand All @@ -96,42 +166,23 @@ jobs:
- name: Checkout code
uses: actions/checkout@v1

- name: Build
run: |
./scripts/tests/werf_with_coverage.sh
./scripts/ci/crane.sh
./scripts/ci/ginkgo.sh
- name: Upload test tools artifact
uses: actions/upload-artifact@master
with:
name: integration_tests_tools
path: bin/tests

integration_tests:
name: Integration tests
needs: prepare_integration_tests_tools
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:

- name: Set up Go 1.12
uses: actions/setup-go@v1
- name: Download go modules artifact
uses: actions/download-artifact@master
with:
go-version: 1.12
id: go
name: go_modules_${{ matrix.os }}
path: .
if: matrix.os == 'ubuntu-latest'

- name: Checkout code
uses: actions/checkout@v1
- name: Unpack go modules (ubuntu-latest)
run: mkdir -p ~/go/pkg/mod && tar -xzvf go_modules.tar.gz -C ~/go/pkg/mod
if: matrix.os == 'ubuntu-latest'

- name: Download test tools artifact
uses: actions/download-artifact@master
with:
name: integration_tests_tools
path: bin/tests
if: matrix.os == 'ubuntu-latest'

- name: Prepare environment
run: |
Expand Down Expand Up @@ -164,7 +215,7 @@ jobs:

integration_k8s_tests:
name: Integration k8s tests
needs: prepare_integration_tests_tools
needs: prepare_go_modules_and_test_tools
strategy:
fail-fast: false
matrix:
Expand All @@ -183,11 +234,23 @@ jobs:
- name: Checkout code
uses: actions/checkout@v1

- name: Download go modules artifact
uses: actions/download-artifact@master
with:
name: go_modules_${{ matrix.os }}
path: .
if: matrix.os == 'ubuntu-latest'

- name: Unpack go modules (ubuntu-latest)
run: mkdir -p ~/go/pkg/mod && tar -xzvf go_modules.tar.gz -C ~/go/pkg/mod
if: matrix.os == 'ubuntu-latest'

- name: Download test tools artifact
uses: actions/download-artifact@master
with:
name: integration_tests_tools
path: bin/tests
if: matrix.os == 'ubuntu-latest'

- name: Prepare environment
run: |
Expand Down

0 comments on commit 38f6f40

Please sign in to comment.