fix: reduce test run time #1
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: | |
test-run: | |
name: Running 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: 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 | |
make test | |
env: | |
S3MOCK_ENDPOINT: localhost:4566 | |
DYNAMODBMOCK_ENDPOINT: http://localhost:4566 | |
AWS_ACCESS_KEY_ID: fake | |
AWS_SECRET_ACCESS_KEY: fake | |
- name: run zot privileged tests | |
run: | | |
sudo env "PATH=$PATH" make privileged-test | |
- if: matrix.os == 'linux' && matrix.arch == 'amd64' | |
- 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 | |
- name: merge code coverage | |
run: | | |
make covhtml | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |