Skip to content

Commit

Permalink
Merge pull request #4744 from werf/ci-test-buildjet
Browse files Browse the repository at this point in the history
ci: add Daily Tests via Buildjet PoC
  • Loading branch information
ilya-lesikov committed Aug 9, 2022
2 parents c6c0a06 + ebd6e77 commit 1698925
Show file tree
Hide file tree
Showing 5 changed files with 319 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/commit_tests.yml
Expand Up @@ -31,6 +31,7 @@ jobs:
run: |
sudo apt-get -y update && sudo apt-get install -y gcc-aarch64-linux-gnu libbtrfs-dev
./scripts/ci/git.sh
task -p deps:install:ginkgo
- name: Tests
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/daily_tests.yml
Expand Up @@ -208,7 +208,7 @@ jobs:
./scripts/ci/git.sh
task deps:install:ginkgo
task -p deps:install:ginkgo
chmod +x werf_with_coverage
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down Expand Up @@ -335,7 +335,7 @@ jobs:
./scripts/ci/git.sh
./scripts/ci/integration_tests_registries_login.sh ${{ matrix.implementation }}
task deps:install:ginkgo
task -p deps:install:ginkgo
chmod +x werf_with_coverage
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down Expand Up @@ -398,7 +398,7 @@ jobs:
./scripts/ci/git.sh
task deps:install:ginkgo
task -p deps:install:ginkgo
chmod +x werf_with_coverage
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down Expand Up @@ -531,7 +531,7 @@ jobs:
./scripts/ci/integration_tests_registries_login.sh quay
./scripts/ci/integration_tests_registries_login.sh github
task deps:install:ginkgo
task -p deps:install:ginkgo
chmod +x werf_with_coverage
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down
301 changes: 301 additions & 0 deletions .github/workflows/daily_tests_buildjet.yml
@@ -0,0 +1,301 @@
name: Daily Tests Buildjet

on:
repository_dispatch:
types: [daily_tests_buildjet]

env:
DEBIAN_FRONTEND: "noninteractive"

jobs:

precompiled_tests_binaries:
name: Precompiled tests binaries
strategy:
fail-fast: false
matrix:
os: [ buildjet-32vcpu-ubuntu-2204 ]
runs-on: ${{ matrix.os }}
steps:

- name: Install werf build dependencies
run: sudo apt-get install -y libbtrfs-dev

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

- name: Set up Go
uses: actions/setup-go@v3
with:
cache: true
go-version-file: go.mod

- name: Install upx (macOS)
run: brew install upx || true
if: matrix.os == 'macOS'

- name: Compile tests binaries
run: |
./scripts/tests/werf_with_coverage.sh
shell: bash

- name: Upload werf with coverage binary (ubuntu, macOS)
uses: actions/upload-artifact@master
with:
name: "${{ matrix.os }}_werf_with_coverage"
path: bin/tests/werf_with_coverage
if: matrix.os != 'windows'

- name: Upload werf with coverage binary (windows)
uses: actions/upload-artifact@master
with:
name: "${{ matrix.os }}_werf_with_coverage"
path: bin/tests/werf_with_coverage.exe
if: matrix.os == 'windows'

unit_tests:
name: Unit tests
needs: precompiled_tests_binaries
if: ${{ success() || failure() }}
strategy:
fail-fast: false
matrix:
os: [ buildjet-32vcpu-ubuntu-2204 ]
# os: [ubuntu, macOS, windows]
runs-on: ${{ matrix.os }}
steps:

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

- name: Set up Go
uses: actions/setup-go@v3
with:
cache: true
go-version-file: go.mod

- name: Prepare environment
run: |
export WERF_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/unit_tests/${{ matrix.os }}
mkdir -p $WERF_TEST_COVERAGE_DIR
echo WERF_TEST_COVERAGE_DIR=$WERF_TEST_COVERAGE_DIR >> $GITHUB_ENV
./scripts/ci/git.sh
task -p deps:install:ginkgo
shell: bash

- name: Test
run: task -p test:unit -- --coverprofile="$WERF_TEST_COVERAGE_DIR/coverage.out" -v --keep-going

- name: Upload coverage artifact
uses: actions/upload-artifact@master
with:
name: tests_coverage
path: tests_coverage

integration_default_tests:
name: Integration default tests
needs: precompiled_tests_binaries
if: ${{ success() || failure() }}
strategy:
fail-fast: false
matrix:
os: [ buildjet-32vcpu-ubuntu-2204 ]
runs-on: ${{ matrix.os }}
env:
WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_ACR: 1
WERF_TEST_ACR_PASSWORD: ${{ secrets.WERF_TEST_ACR_PASSWORD }}
WERF_TEST_ACR_REGISTRY: ${{ secrets.WERF_TEST_ACR_REGISTRY }}
WERF_TEST_ACR_USERNAME: ${{ secrets.WERF_TEST_ACR_USERNAME }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_DEFAULT: 1
WERF_TEST_DEFAULT_PASSWORD: ${{ secrets.WERF_TEST_DEFAULT_PASSWORD }}
WERF_TEST_DEFAULT_REGISTRY: ${{ secrets.WERF_TEST_DEFAULT_REGISTRY }}
WERF_TEST_DEFAULT_USERNAME: ${{ secrets.WERF_TEST_DEFAULT_USERNAME }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_DOCKERHUB: 0
WERF_TEST_DOCKERHUB_PASSWORD: ${{ secrets.WERF_TEST_DOCKERHUB_PASSWORD }}
WERF_TEST_DOCKERHUB_REGISTRY: ${{ secrets.WERF_TEST_DOCKERHUB_REGISTRY }}
WERF_TEST_DOCKERHUB_USERNAME: ${{ secrets.WERF_TEST_DOCKERHUB_USERNAME }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_ECR: 1
WERF_TEST_ECR_REGISTRY: ${{ secrets.WERF_TEST_ECR_REGISTRY }}
WERF_TEST_ECR_PASSWORD: ${{ secrets.WERF_TEST_ECR_PASSWORD }}
WERF_TEST_ECR_USERNAME: ${{ secrets.WERF_TEST_ECR_USERNAME }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_GCR: 1
WERF_TEST_GCR_BASE64_CONFIG: ${{ secrets.WERF_TEST_GCR_BASE64_CONFIG }}
WERF_TEST_GCR_REGISTRY: ${{ secrets.WERF_TEST_GCR_REGISTRY }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_GITHUB: 1
WERF_TEST_GITHUB_PASSWORD: ${{ secrets.WERF_TEST_GITHUB_PASSWORD }}
WERF_TEST_GITHUB_REGISTRY: ${{ secrets.WERF_TEST_GITHUB_REGISTRY }}
WERF_TEST_GITHUB_TOKEN: ${{ secrets.WERF_TEST_GITHUB_TOKEN }}
WERF_TEST_GITHUB_USERNAME: ${{ secrets.WERF_TEST_GITHUB_USERNAME }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_HARBOR: 1
WERF_TEST_HARBOR_PASSWORD: ${{ secrets.WERF_TEST_HARBOR_PASSWORD }}
WERF_TEST_HARBOR_REGISTRY: ${{ secrets.WERF_TEST_HARBOR_REGISTRY }}
WERF_TEST_HARBOR_USERNAME: ${{ secrets.WERF_TEST_HARBOR_USERNAME }}

WERF_TEST_DOCKER_REGISTRY_IMPLEMENTATION_QUAY: 0
WERF_TEST_QUAY_PASSWORD: ${{ secrets.WERF_TEST_QUAY_PASSWORD }}
WERF_TEST_QUAY_REGISTRY: ${{ secrets.WERF_TEST_QUAY_REGISTRY }}
WERF_TEST_QUAY_TOKEN: ${{ secrets.WERF_TEST_QUAY_TOKEN }}
WERF_TEST_QUAY_USERNAME: ${{ secrets.WERF_TEST_QUAY_USERNAME }}
steps:

- name: Checkout code
uses: actions/checkout@v3
# if: matrix.extra-find-args != '! -name ''git.test'' ! -name ''ansible.test'''

# - name: Checkout code (git history as fixtures for tests)
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# if: matrix.extra-find-args == '! -name ''git.test'' ! -name ''ansible.test'''

- name: Set up Go
uses: actions/setup-go@v3
with:
cache: true
go-version-file: go.mod

- name: Install Task
uses: arduino/setup-task@v1

- name: Download werf with coverage binary
uses: actions/download-artifact@master
with:
name: "${{ matrix.os }}_werf_with_coverage"
path: .

- name: Login (acr)
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Login (ecr)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: Prepare environment
run: |
export WERF_TEST_COVERAGE_DIR=$GITHUB_WORKSPACE/tests_coverage/integration_default_tests/${{ matrix.os }}
mkdir -p $WERF_TEST_COVERAGE_DIR
echo WERF_TEST_COVERAGE_DIR=$WERF_TEST_COVERAGE_DIR >> $GITHUB_ENV
./scripts/ci/git.sh
for impl in acr default dockerhub ecr gcr github harbor quay; do
./scripts/ci/integration_tests_registries_login.sh $impl
done
task -p deps:install:ginkgo
chmod +x werf_with_coverage
shell: bash

- name: Test
run: |
echo WERF_TEST_K8S_BASE64_KUBECONFIG=$(printenv WERF_TEST_K8S_BASE64_KUBECONFIG_$(echo 1.19 | tr . _)) >> $GITHUB_ENV
source ./scripts/ci/integration_k8s_tests_before_hook.sh
WERF_TEST_BINARY_PATH=$GITHUB_WORKSPACE/werf_with_coverage task -p test:integration -- --flake-attempts=3 --coverprofile="$WERF_TEST_COVERAGE_DIR/coverage.out" -v --keep-going
shell: bash
env:
WERF_TEST_K8S_BASE64_KUBECONFIG_1_19: ${{ secrets.WERF_TEST_K8S_BASE64_KUBECONFIG_1_19 }}
WERF_TEST_K8S_DOCKER_REGISTRY: ${{ secrets.WERF_TEST_K8S_DOCKER_REGISTRY }}
WERF_TEST_K8S_DOCKER_REGISTRY_USERNAME: ${{ secrets.WERF_TEST_K8S_DOCKER_REGISTRY_USERNAME }}
WERF_TEST_K8S_DOCKER_REGISTRY_PASSWORD: ${{ secrets.WERF_TEST_K8S_DOCKER_REGISTRY_PASSWORD }}

- name: Upload coverage artifact
uses: actions/upload-artifact@master
with:
name: tests_coverage
path: tests_coverage

upload_coverage:
name: Upload coverage
needs:
- unit_tests
- integration_default_tests
runs-on: buildjet-32vcpu-ubuntu-2204
steps:

- name: Install werf build dependencies
run: sudo apt-get install -y libbtrfs-dev

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

- name: Set up Go
uses: actions/setup-go@v3
with:
cache: true
go-version-file: 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 WERF_TEST_COVERAGE_DIR=tests_coverage >> $GITHUB_ENV
- name: Prepare coverage file
run: |
# FIXME: determine problems with coverage records and remove seds
find $WERF_TEST_COVERAGE_DIR -type f -exec \
sed -i -e "s|/home/ubuntu/actions-runner/_work/werf/werf|github.com/werf/werf|g" {} +
find $WERF_TEST_COVERAGE_DIR -type f -exec \
sed -i -e "s|/home/runner/work/werf/werf|github.com/werf/werf|g" {} +
find $WERF_TEST_COVERAGE_DIR -type f -exec \
sed -i -e "s|/Users/runner/runners/[0-9.]*/work/werf/werf|github.com/werf/werf|g" {} +
find $WERF_TEST_COVERAGE_DIR -type f -exec \
sed -i -e 's|D:\\a\\werf\\werf\\cmd\\werf\\main.go|github.com/werf/werf/cmd/werf/main.go|g' {} +
coverage_files=$(find $WERF_TEST_COVERAGE_DIR -name '*.out')
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/werf/ \
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: buildjet-32vcpu-ubuntu-2204
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"
10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Expand Up @@ -55,7 +55,9 @@ jobs:
uses: arduino/setup-task@v1

- name: Prepare environment
run: ./scripts/ci/git.sh
run: |
./scripts/ci/git.sh
task -p deps:install:ginkgo
- name: Test
run: task -p test:unit
Expand Down Expand Up @@ -173,7 +175,7 @@ jobs:
run: |
./scripts/ci/git.sh
task deps:install:ginkgo
task -p deps:install:ginkgo
chmod +x werf
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down Expand Up @@ -227,7 +229,7 @@ jobs:
run: |
./scripts/ci/git.sh
task deps:install:ginkgo
task -p deps:install:ginkgo
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down Expand Up @@ -352,7 +354,7 @@ jobs:
./scripts/ci/integration_tests_registries_login.sh quay
./scripts/ci/integration_tests_registries_login.sh github
task deps:install:ginkgo
task -p deps:install:ginkgo
find integration -type f -name '*.test' -exec chmod +x {} \;
Expand Down

0 comments on commit 1698925

Please sign in to comment.