mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
fix: reduce test run time (#1832)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
@@ -23,7 +23,6 @@ jobs:
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config
|
||||
mkdir -p test/data
|
||||
cd test/data
|
||||
../scripts/gen_certs.sh
|
||||
@@ -36,6 +35,6 @@ jobs:
|
||||
for i in $(find . -type f \( -name "*.go" -not -name "*_test.go" -not -name "generated.go" \)); do
|
||||
echo $i;
|
||||
gobco -test '-tags=sync,search,scrub,metrics,containers_image_openpgp' $i;
|
||||
gobco -test '-tags=minimal,containers_image_openpgp' $i;
|
||||
gobco -test '-tags=containers_image_openpgp' $i;
|
||||
done
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
name: build
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-arch:
|
||||
name: Build ZOT multiarch
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os: [linux, darwin, freebsd]
|
||||
arch: [amd64, arm64]
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/clean-runner
|
||||
- name: Install go
|
||||
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: Cache go build output
|
||||
id: cache-go-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
key: ${{ matrix.os }}-${{ matrix.arch }}-go-build-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ matrix.os }}-${{ matrix.arch }}-go-build-
|
||||
- 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/swaggo/swag/cmd/swag@v1.8.12
|
||||
sudo apt-get update
|
||||
sudo apt-get install rpm
|
||||
sudo apt-get install snapd
|
||||
sudo apt-get install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config
|
||||
git clone https://github.com/containers/skopeo -b v1.12.0 $GITHUB_WORKSPACE/src/github.com/containers/skopeo
|
||||
cd $GITHUB_WORKSPACE/src/github.com/containers/skopeo && \
|
||||
make bin/skopeo && \
|
||||
sudo cp bin/skopeo /usr/bin && \
|
||||
rm -rf $GITHUB_WORKSPACE/src/github.com/containers/skopeo
|
||||
cd $GITHUB_WORKSPACE
|
||||
curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v1.0.0-rc.4/notation_1.0.0-rc.4_linux_amd64.tar.gz
|
||||
sudo tar xvzf notation.tar.gz -C /usr/bin notation
|
||||
rm -f notation.tar.gz
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- name: Run build
|
||||
timeout-minutes: 80
|
||||
run: |
|
||||
echo "Building for $OS:$ARCH"
|
||||
cd $GITHUB_WORKSPACE
|
||||
make binary binary-minimal binary-debug cli bench exporter-minimal
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
|
||||
- name: Generate GraphQL Introspection JSON on Release
|
||||
if: github.event_name == 'release' && github.event.action == 'published' && matrix.os == 'linux' && matrix.arch == 'amd64'
|
||||
run: |
|
||||
bin/zot-linux-amd64 serve examples/config-search.json &
|
||||
sleep 10
|
||||
curl -X POST -H "Content-Type: application/json" -d @.pkg/debug/githubWorkflows/introspection-query.json http://localhost:5000/v2/_zot/ext/search | jq > bin/zot-gql-introspection-result.json
|
||||
pkill zot
|
||||
|
||||
- if: github.event_name == 'release' && github.event.action == 'published'
|
||||
name: Publish artifacts on releases
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: bin/z*
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
file_glob: true
|
||||
@@ -14,7 +14,7 @@ permissions: read-all
|
||||
jobs:
|
||||
client-tools:
|
||||
name: Stateless zot with shared reliable storage
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-latest
|
||||
# services:
|
||||
# minio:
|
||||
# image: minio/minio:edge-cicd
|
||||
|
||||
@@ -51,15 +51,6 @@ jobs:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
go install github.com/swaggo/swag/cmd/swag@v1.8.12
|
||||
go mod download
|
||||
go install github.com/wadey/gocovmerge@latest
|
||||
go get -u github.com/swaggo/swag/cmd/swag
|
||||
go mod download
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2.21.8
|
||||
|
||||
+6
-6
@@ -36,11 +36,11 @@ jobs:
|
||||
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zot-minimal binary size is not affected by PR" && exit 0
|
||||
|
||||
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
||||
PERCENTAGE=$(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc); \
|
||||
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
||||
echo "zot minimal binary increased by $PERCENTAGE% comparing with main"; \
|
||||
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
||||
else \
|
||||
PERCENTAGE=$(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc); \
|
||||
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
||||
echo "zot minimal binary decreased by $PERCENTAGE% comparing with main"; \
|
||||
fi
|
||||
- if: always()
|
||||
@@ -61,11 +61,11 @@ jobs:
|
||||
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zb binary size is not affected by PR" && exit 0
|
||||
|
||||
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
||||
PERCENTAGE=$(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc); \
|
||||
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
||||
echo "zb binary increased by $PERCENTAGE% comparing with main"; \
|
||||
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
||||
else \
|
||||
PERCENTAGE=$(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc); \
|
||||
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
||||
echo "zb binary decreased by $PERCENTAGE% comparing with main"; \
|
||||
fi
|
||||
- if: always()
|
||||
@@ -86,10 +86,10 @@ jobs:
|
||||
[[ $BINSIZE -eq $BINSIZE_MAIN ]] && echo "zli binary size is not affected by PR" && exit 0
|
||||
|
||||
if [[ $BINSIZE -gt $BINSIZE_MAIN ]]; then \
|
||||
PERCENTAGE=$(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc); \
|
||||
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE-$BINSIZE_MAIN)*100)/$BINSIZE_MAIN" | bc)); \
|
||||
echo "zli binary increased by $PERCENTAGE% comparing with main"; \
|
||||
if ((`bc <<< "$PERCENTAGE>=1.0"`)); then exit 1; fi; \
|
||||
else \
|
||||
PERCENTAGE=$(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc); \
|
||||
PERCENTAGE=$(printf '%.*f\n' 2 $(echo "scale=2; (($BINSIZE_MAIN-$BINSIZE)*100)/$BINSIZE_MAIN" | bc)); \
|
||||
echo "zli binary decreased by $PERCENTAGE% comparing with main"; \
|
||||
fi
|
||||
@@ -1,4 +1,3 @@
|
||||
# .github/workflows/dco.yml
|
||||
name: DCO
|
||||
on:
|
||||
pull_request:
|
||||
@@ -22,7 +22,6 @@ jobs:
|
||||
with:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
- uses: ./.github/actions/clean-runner
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
@@ -54,21 +53,7 @@ jobs:
|
||||
make bin/dex
|
||||
./bin/dex serve $GITHUB_WORKSPACE/test/dex/config-dev.yaml &
|
||||
cd $GITHUB_WORKSPACE
|
||||
- name: Check disk space before build
|
||||
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
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- name: Run CI tests
|
||||
run: |
|
||||
make run-blackbox-ci
|
||||
@@ -76,7 +61,7 @@ jobs:
|
||||
run: |
|
||||
pip install --upgrade pyopenssl
|
||||
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal
|
||||
docker pull localstack/localstack # Make sure to pull the latest version of the image
|
||||
docker pull localstack/localstack:2.2 # 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
|
||||
@@ -88,19 +73,5 @@ jobs:
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
- name: Check disk space after build
|
||||
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
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
run: |
|
||||
cat /tmp/gc-bench-local.log
|
||||
exit 1
|
||||
|
||||
|
||||
gc-referrers-stress-s3:
|
||||
name: GC(with referrers) on S3(minio) with short interval
|
||||
runs-on: ubuntu-latest
|
||||
@@ -86,21 +86,7 @@ jobs:
|
||||
with:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
- 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
|
||||
- uses: ./.github/actions/setup-localstack
|
||||
- name: Setup minio service
|
||||
run: |
|
||||
docker run -d -p 9000:9000 --name minio \
|
||||
@@ -164,6 +150,7 @@ jobs:
|
||||
run: |
|
||||
cat /tmp/gc-referrers-bench-s3.log
|
||||
exit 1
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
|
||||
gc-stress-s3:
|
||||
name: GC(without referrers) on S3(minio) with short interval
|
||||
@@ -175,21 +162,7 @@ jobs:
|
||||
with:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
- 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
|
||||
- uses: ./.github/actions/setup-localstack
|
||||
- name: Setup minio service
|
||||
run: |
|
||||
docker run -d -p 9000:9000 --name minio \
|
||||
@@ -253,3 +226,4 @@ jobs:
|
||||
run: |
|
||||
cat /tmp/gc-bench-s3.log
|
||||
exit 1
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
cache: false
|
||||
go-version: '1.20'
|
||||
- uses: actions/checkout@v4
|
||||
- name: golangci-lint
|
||||
- name: Run linter with GH action
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||
@@ -41,3 +41,6 @@ jobs:
|
||||
|
||||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
|
||||
# skip-build-cache: true
|
||||
- name: Run linter from make target
|
||||
run: |
|
||||
make check
|
||||
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
run: |
|
||||
pip install --upgrade pyopenssl
|
||||
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal
|
||||
docker pull localstack/localstack # Make sure to pull the latest version of the image
|
||||
docker pull localstack/localstack:2.2 # 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
|
||||
@@ -52,6 +52,8 @@ jobs:
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
|
||||
sync:
|
||||
name: Sync harness
|
||||
runs-on: ubuntu-latest
|
||||
@@ -81,21 +83,7 @@ jobs:
|
||||
with:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
- 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
|
||||
- uses: ./.github/actions/setup-localstack
|
||||
|
||||
- name: Run zb
|
||||
id: bench
|
||||
@@ -120,6 +108,7 @@ jobs:
|
||||
run: |
|
||||
cat /tmp/gc-referrers-bench-s3.log
|
||||
exit 1
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
|
||||
gc-stress-s3:
|
||||
name: GC(without referrers) on S3(localstack) with short interval
|
||||
@@ -131,21 +120,7 @@ jobs:
|
||||
with:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
- 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
|
||||
- uses: ./.github/actions/setup-localstack
|
||||
|
||||
- name: Run zb
|
||||
id: bench
|
||||
@@ -170,3 +145,4 @@ jobs:
|
||||
run: |
|
||||
cat /tmp/gc-bench-s3.log
|
||||
exit 1
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
|
||||
@@ -1,178 +1,13 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
name: build-test
|
||||
name: publish
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build-test-arch:
|
||||
name: Build and test ZOT
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os: [linux, darwin, freebsd]
|
||||
arch: [amd64, arm64]
|
||||
steps:
|
||||
- name: Check out source code
|
||||
uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/clean-runner
|
||||
- name: Install go
|
||||
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: Cache go build output
|
||||
id: cache-go-build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
key: ${{ matrix.os }}-${{ matrix.arch }}-go-build-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ matrix.os }}-${{ matrix.arch }}-go-build-
|
||||
- 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/swaggo/swag/cmd/swag@v1.8.12
|
||||
sudo apt-get update
|
||||
sudo apt-get install rpm
|
||||
sudo apt-get install snapd
|
||||
sudo apt-get install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config
|
||||
git clone https://github.com/containers/skopeo -b v1.12.0 $GITHUB_WORKSPACE/src/github.com/containers/skopeo
|
||||
cd $GITHUB_WORKSPACE/src/github.com/containers/skopeo && \
|
||||
make bin/skopeo && \
|
||||
sudo cp bin/skopeo /usr/bin && \
|
||||
rm -rf $GITHUB_WORKSPACE/src/github.com/containers/skopeo
|
||||
cd $GITHUB_WORKSPACE
|
||||
curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v1.0.0-rc.4/notation_1.0.0-rc.4_linux_amd64.tar.gz
|
||||
sudo tar xvzf notation.tar.gz -C /usr/bin notation
|
||||
rm -f notation.tar.gz
|
||||
go install github.com/wadey/gocovmerge@latest
|
||||
|
||||
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
|
||||
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 build
|
||||
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 build and test
|
||||
timeout-minutes: 80
|
||||
run: |
|
||||
echo "Building for $OS:$ARCH"
|
||||
cd $GITHUB_WORKSPACE
|
||||
if [[ $OS == "linux" && $ARCH == "amd64" ]]; then
|
||||
make
|
||||
sudo env "PATH=$PATH" make privileged-test
|
||||
else
|
||||
make binary binary-minimal binary-debug cli bench exporter-minimal
|
||||
fi
|
||||
env:
|
||||
S3MOCK_ENDPOINT: localhost:4566
|
||||
DYNAMODBMOCK_ENDPOINT: http://localhost:4566
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
OS: ${{ matrix.os }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
|
||||
- if: matrix.os == 'linux' && matrix.arch == 'amd64'
|
||||
name: Stop localstack
|
||||
run: |
|
||||
localstack stop
|
||||
|
||||
- name: Check disk space after build
|
||||
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: Upload code coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
- name: Generate GraphQL Introspection JSON on Release
|
||||
if: github.event_name == 'release' && github.event.action == 'published' && matrix.os == 'linux' && matrix.arch == 'amd64'
|
||||
run: |
|
||||
bin/zot-linux-amd64 serve examples/config-search.json &
|
||||
sleep 10
|
||||
curl -X POST -H "Content-Type: application/json" -d @.pkg/debug/githubWorkflows/introspection-query.json http://localhost:5000/v2/_zot/ext/search | jq > bin/zot-gql-introspection-result.json
|
||||
pkill zot
|
||||
|
||||
- if: github.event_name == 'release' && github.event.action == 'published'
|
||||
name: Publish artifacts on releases
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: bin/z*
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
file_glob: true
|
||||
|
||||
push-image:
|
||||
if: github.event_name == 'release' && github.event.action== 'published'
|
||||
name: Push OCI images to GitHub Packages
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
@@ -0,0 +1,159 @@
|
||||
name: "Running tests"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches: [main]
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
test-run-minimal:
|
||||
name: Running zot without extensions tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/clean-runner
|
||||
- name: Install go
|
||||
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
|
||||
- uses: ./.github/actions/setup-localstack
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- name: run zot minimal tests
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
make test-minimal
|
||||
env:
|
||||
S3MOCK_ENDPOINT: localhost:4566
|
||||
DYNAMODBMOCK_ENDPOINT: http://localhost:4566
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
- name: upload coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-minimal
|
||||
path: coverage-minimal.txt
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
test-run-extensions:
|
||||
name: Run zot with extensions tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/clean-runner
|
||||
- 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
|
||||
- uses: ./.github/actions/setup-localstack
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- name: run zot extended tests
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
make test-extended
|
||||
env:
|
||||
S3MOCK_ENDPOINT: localhost:4566
|
||||
DYNAMODBMOCK_ENDPOINT: http://localhost:4566
|
||||
AWS_ACCESS_KEY_ID: fake
|
||||
AWS_SECRET_ACCESS_KEY: fake
|
||||
- name: upload coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-extended
|
||||
path: coverage-extended.txt
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- uses: ./.github/actions/teardown-localstack
|
||||
test-run-devmode:
|
||||
name: Running privileged tests on Linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/clean-runner
|
||||
- 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
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
- name: run zot development-mode unit tests (possibly using failure injection)
|
||||
run: make test-devmode
|
||||
- name: run zot privileged tests
|
||||
run: sudo env "PATH=$PATH" make privileged-test
|
||||
- name: upload coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-devmode
|
||||
path: coverage-dev-*.txt
|
||||
- uses: ./.github/actions/check-diskspace
|
||||
test-coverage:
|
||||
name: Collect all test coverage
|
||||
runs-on: ubuntu-latest
|
||||
if: always()
|
||||
needs: [test-run-minimal,test-run-extensions,test-run-devmode]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
cache: false
|
||||
go-version: 1.20.x
|
||||
- name: download all workflow coverage files
|
||||
uses: actions/download-artifact@v3
|
||||
- name: merge code coverage
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
cp coverage-minimal/* .
|
||||
cp coverage-extended/* .
|
||||
cp coverage-devmode/* .
|
||||
make covhtml
|
||||
- name: upload code coverage
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user