Skip to content

Tests

Tests #1594

Workflow file for this run

name: Tests
on:
push:
paths:
- 'client/scripts/ci'
- 'client/scripts/minio'
- '.github/workflows/tests.yml'
- '**/*.go'
- go.mod
schedule:
- cron: '0 8 * * *'
repository_dispatch:
types: [ tests ]
workflow_dispatch:
jobs:
tests:
name: Tests
strategy:
fail-fast: false
matrix:
directory: [ server ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: ${{ matrix.directory }}/go.mod
- name: Prepare environment
run: |
# coverage directory
export TRDL_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/tests/${{ matrix.os }}/${{ matrix.directory }}
mkdir -p $TRDL_TEST_COVERAGE_DIR
echo TRDL_TEST_COVERAGE_DIR=$TRDL_TEST_COVERAGE_DIR >> $GITHUB_ENV
# git user
./e2e/scripts/ci/git.sh
# install gpg
sudo apt-get update
sudo apt-get install gpg
# install git-signatures
git clone https://github.com/werf/3p-git-signatures.git
cd 3p-git-signatures
make install
echo "~/.local/bin" >> $GITHUB_PATH
# install ginkgo
go install github.com/onsi/ginkgo/v2/ginkgo@latest
shell: bash
- name: Test
working-directory: ${{ matrix.directory }}
run: ginkgo -vet=off -race -keepGoing -cover -coverpkg=./... -outputdir=$TRDL_TEST_COVERAGE_DIR ./...
- name: Upload coverage artifact
uses: actions/upload-artifact@master
with:
name: tests_coverage
path: tests_coverage
e2e_tests:
name: End-to-end tests
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: e2e/go.mod
- name: Prepare environment
working-directory: e2e
run: |
# coverage directory
export TRDL_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/e2e/${{ matrix.os }}
mkdir -p $TRDL_TEST_COVERAGE_DIR
echo TRDL_TEST_COVERAGE_DIR=$TRDL_TEST_COVERAGE_DIR >> $GITHUB_ENV
# coverage trdl binary
./scripts/ci/trdl_with_coverage.sh
export TRDL_TEST_BINARY_PATH=$GITHUB_WORKSPACE/e2e/bin/tests/trdl_with_coverage
chmod +x $TRDL_TEST_BINARY_PATH
echo TRDL_TEST_BINARY_PATH=$TRDL_TEST_BINARY_PATH >> $GITHUB_ENV
# git user
./scripts/ci/git.sh
# install gpg
sudo apt-get update
sudo apt-get install gpg
# install git-signatures
git clone https://github.com/werf/3p-git-signatures.git
cd 3p-git-signatures
make install
echo "~/.local/bin" >> $GITHUB_PATH
go install github.com/onsi/ginkgo/v2/ginkgo@latest
- name: Test
working-directory: e2e
run: ginkgo -p -keepGoing -cover -coverpkg=../client/...,../server/... -outputdir=$TRDL_TEST_COVERAGE_DIR ./...
- name: Upload coverage artifact
uses: actions/upload-artifact@master
with:
name: tests_coverage
path: tests_coverage
upload_coverage:
name: Upload coverage
needs:
- tests
- e2e_tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: e2e/go.mod
- name: Download coverage artifact
uses: actions/download-artifact@master
with:
name: tests_coverage
path: tests_coverage
- name: Prepare environment
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
go install github.com/wadey/gocovmerge@latest
echo TRDL_TEST_COVERAGE_DIR=tests_coverage >> $GITHUB_ENV
- name: Prepare coverage file
run: |
find $TRDL_TEST_COVERAGE_DIR -type f -exec \
sed -i -e "s|/home/ubuntu/actions-runner/_work/werf/trdl|github.com/werf/trdl|g" {} +
coverage_files=$(find $TRDL_TEST_COVERAGE_DIR -type f)
gocovmerge ${coverage_files[@]} > coverage.out
- name: Format and upload
run: |
export GIT_BRANCH=${GITHUB_REF:11}
export GIT_COMMIT_SHA=$GITHUB_SHA
./cc-test-reporter format-coverage \
-t=gocov \
-p=github.com/werf/trdl/ \
coverage.out
./cc-test-reporter upload-coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
notification:
name: Notification
if: always()
needs: upload_coverage
runs-on: ubuntu-latest
steps:
- uses: technote-space/workflow-conclusion-action@v2
- name: Notify
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: ${{ env.WORKFLOW_CONCLUSION }}
MSG_MINIMAL: "ref,actions url"