fix: reduce test run time #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Running tests" | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: [main] | |
release: | |
types: | |
- published | |
permissions: read-all | |
jobs: | |
privileged-test: | |
name: Running privileged tests on Linux | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
cache: false | |
go-version: 1.20.x | |
- name: Cache go dependencies | |
id: cache-go-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-mod- | |
- name: Install go dependencies | |
if: steps.cache-go-dependencies.outputs.cache-hit != 'true' | |
run: | | |
cd $GITHUB_WORKSPACE | |
go mod download | |
- name: Check disk space before running tests | |
run: | | |
cd $GITHUB_WORKSPACE | |
set -x | |
df -h | |
sudo ls -lRh /tmp/* || true | |
sudo du -sh /tmp || true | |
sudo du -sh /tmp/* || true | |
sudo find /tmp/ -size +5M | sudo xargs ls -lh | |
du -sh ./* || true | |
find ./ -size +5M | xargs ls -lh | |
sudo du -sh /var/ | |
sudo du -sh /var/lib/docker/ | |
du -sh /home/runner/work/ | |
set +x | |
- name: run zot privileged tests | |
run: | | |
sudo env "PATH=$PATH" make privileged-test | |
- name: Check disk space after running tests | |
if: always() | |
run: | | |
cd $GITHUB_WORKSPACE | |
set -x | |
df -h | |
sudo ls -lRh /tmp/* || true | |
sudo du -sh /tmp || true | |
sudo du -sh /tmp/* || true | |
sudo find /tmp/ -size +5M | sudo xargs ls -lh | |
du -sh ./* || true | |
find ./ -size +5M | xargs ls -lh | |
sudo du -sh /var/ | |
sudo du -sh /var/lib/docker/ | |
du -sh /home/runner/work/ | |
set +x | |
test-run-minimal: | |
name: Running zot without extensions tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
cache: false | |
go-version: 1.20.x | |
- name: Cache go dependencies | |
id: cache-go-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-mod- | |
- name: Install go dependencies | |
if: steps.cache-go-dependencies.outputs.cache-hit != 'true' | |
run: | | |
cd $GITHUB_WORKSPACE | |
go mod download | |
- name: Install other dependencies | |
run: | | |
cd $GITHUB_WORKSPACE | |
go install github.com/wadey/gocovmerge@latest | |
- name: Setup localstack service | |
run: | | |
pip install localstack # Install LocalStack cli | |
docker pull localstack/localstack:1.3 # Make sure to pull the latest version of the image | |
localstack start -d # Start LocalStack in the background | |
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container | |
localstack wait -t 30 # to become ready before timing out | |
echo "Startup complete" | |
aws --endpoint-url=http://localhost:4566 s3api create-bucket --bucket zot-storage --region us-east-2 --create-bucket-configuration="{\"LocationConstraint\": \"us-east-2\"}" | |
aws dynamodb --endpoint-url http://localhost:4566 --region "us-east-2" create-table --table-name BlobTable --attribute-definitions AttributeName=Digest,AttributeType=S --key-schema AttributeName=Digest,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 | |
env: | |
AWS_ACCESS_KEY_ID: fake | |
AWS_SECRET_ACCESS_KEY: fake | |
- name: Check disk space before running tests | |
run: | | |
cd $GITHUB_WORKSPACE | |
set -x | |
df -h | |
sudo ls -lRh /tmp/* || true | |
sudo du -sh /tmp || true | |
sudo du -sh /tmp/* || true | |
sudo find /tmp/ -size +5M | sudo xargs ls -lh | |
du -sh ./* || true | |
find ./ -size +5M | xargs ls -lh | |
sudo du -sh /var/ | |
sudo du -sh /var/lib/docker/ | |
du -sh /home/runner/work/ | |
set +x | |
- name: run zot tests minimal | |
run: | | |
echo "Test run on $OS:$ARCH" | |
cd $GITHUB_WORKSPACE | |
go test -failfast -tags containers_image_openpgp -trimpath -race -cover -coverpkg ./... -coverprofile=coverage-minimal.txt -covermode=atomic ./... | |
rm -rf /tmp/getter*; rm -rf /tmp/trivy* | |
env: | |
S3MOCK_ENDPOINT: localhost:4566 | |
DYNAMODBMOCK_ENDPOINT: http://localhost:4566 | |
AWS_ACCESS_KEY_ID: fake | |
AWS_SECRET_ACCESS_KEY: fake | |
- name: Check disk space after running tests | |
if: always() | |
run: | | |
cd $GITHUB_WORKSPACE | |
set -x | |
df -h | |
sudo ls -lRh /tmp/* || true | |
sudo du -sh /tmp || true | |
sudo du -sh /tmp/* || true | |
sudo find /tmp/ -size +5M | sudo xargs ls -lh | |
du -sh ./* || true | |
find ./ -size +5M | xargs ls -lh | |
sudo du -sh /var/ | |
sudo du -sh /var/lib/docker/ | |
du -sh /home/runner/work/ | |
set +x | |
- name: Stop localstack | |
if: always() | |
run: | | |
localstack stop | |
test-run-extensions: | |
name: run zot with extensions tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
cache: false | |
go-version: 1.20.x | |
- name: Cache go dependencies | |
id: cache-go-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-mod- | |
- name: Install go dependencies | |
if: steps.cache-go-dependencies.outputs.cache-hit != 'true' | |
run: | | |
cd $GITHUB_WORKSPACE | |
go mod download | |
- name: Install other dependencies | |
run: | | |
cd $GITHUB_WORKSPACE | |
go install github.com/wadey/gocovmerge@latest | |
- name: Setup localstack service | |
run: | | |
pip install localstack # Install LocalStack cli | |
docker pull localstack/localstack:1.3 # Make sure to pull the latest version of the image | |
localstack start -d # Start LocalStack in the background | |
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container | |
localstack wait -t 30 # to become ready before timing out | |
echo "Startup complete" | |
aws --endpoint-url=http://localhost:4566 s3api create-bucket --bucket zot-storage --region us-east-2 --create-bucket-configuration="{\"LocationConstraint\": \"us-east-2\"}" | |
aws dynamodb --endpoint-url http://localhost:4566 --region "us-east-2" create-table --table-name BlobTable --attribute-definitions AttributeName=Digest,AttributeType=S --key-schema AttributeName=Digest,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 | |
env: | |
AWS_ACCESS_KEY_ID: fake | |
AWS_SECRET_ACCESS_KEY: fake | |
- name: Check disk space before running tests | |
run: | | |
cd $GITHUB_WORKSPACE | |
set -x | |
df -h | |
sudo ls -lRh /tmp/* || true | |
sudo du -sh /tmp || true | |
sudo du -sh /tmp/* || true | |
sudo find /tmp/ -size +5M | sudo xargs ls -lh | |
du -sh ./* || true | |
find ./ -size +5M | xargs ls -lh | |
sudo du -sh /var/ | |
sudo du -sh /var/lib/docker/ | |
du -sh /home/runner/work/ | |
set +x | |
- name: run zot tests | |
run: | | |
echo "Test run on $OS:$ARCH" | |
cd $GITHUB_WORKSPACE | |
go test -failfast -tags ${BUILD_LABELS},containers_image_openpgp -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile=coverage-extended.txt -covermode=atomic ./... | |
env: | |
S3MOCK_ENDPOINT: localhost:4566 | |
DYNAMODBMOCK_ENDPOINT: http://localhost:4566 | |
AWS_ACCESS_KEY_ID: fake | |
AWS_SECRET_ACCESS_KEY: fake | |
BUILD_LABELS: imagetrust,lint,metrics,mgmt,profile,scrub,search,sync,ui,userprefs | |
- name: Check disk space after running tests | |
if: always() | |
run: | | |
cd $GITHUB_WORKSPACE | |
set -x | |
df -h | |
sudo ls -lRh /tmp/* || true | |
sudo du -sh /tmp || true | |
sudo du -sh /tmp/* || true | |
sudo find /tmp/ -size +5M | sudo xargs ls -lh | |
du -sh ./* || true | |
find ./ -size +5M | xargs ls -lh | |
sudo du -sh /var/ | |
sudo du -sh /var/lib/docker/ | |
du -sh /home/runner/work/ | |
set +x | |
- name: Stop localstack | |
if: always() | |
run: | | |
localstack stop | |
test-coverage: | |
name: generate test coverage | |
runs-on: ubuntu-22.04 | |
if: always() | |
needs: [test-run-minimal,test-run-extensions] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
cache: false | |
go-version: 1.20.x | |
- name: Cache go dependencies | |
id: cache-go-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-mod- | |
- name: Install go dependencies | |
if: steps.cache-go-dependencies.outputs.cache-hit != 'true' | |
run: | | |
cd $GITHUB_WORKSPACE | |
go mod download | |
- name: Install other dependencies | |
run: | | |
cd $GITHUB_WORKSPACE | |
go install github.com/wadey/gocovmerge@latest | |
- name: merge code coverage | |
run: | | |
make covhtml | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |