Skip to content

Commit

Permalink
fix: reduce test run time
Browse files Browse the repository at this point in the history
Signed-off-by: Alexei Dodon <adodon@cisco.com>
  • Loading branch information
adodon2go committed Sep 26, 2023
1 parent 9096031 commit 4ba705e
Show file tree
Hide file tree
Showing 25 changed files with 885 additions and 706 deletions.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions .github/actions/check-diskspace/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Check disk space'
description: 'Show available disk space'
runs:
using: "composite"
steps:
- shell: bash
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
19 changes: 19 additions & 0 deletions .github/actions/setup-localstack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Setup localstack service'
description: 'Download & run localstack container'
runs:
using: "composite"
steps:
- shell: bash
run: |
pip install localstack # Install LocalStack cli
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
localstack wait -t 30 # to become ready before timing out
echo "Startup complete"
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
8 changes: 8 additions & 0 deletions .github/actions/teardown-localstack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'Stop localstack'
description: 'Stop localstack container'
runs:
using: "composite"
steps:
- shell: bash
if: always()
run: localstack stop
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
103 changes: 103 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches:
- main
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '17 11 * * 0'
branches: [main]

permissions: read-all

jobs:
analyze:
name: Analyze
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
Expand All @@ -37,9 +36,6 @@ jobs:
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
env:
CGO_ENABLED: 0
GOFLAGS: "-tags=sync,search,scrub,metrics,userprefs,mgmt,imagetrust,containers_image_openpgp"

steps:
- name: Checkout repository
Expand All @@ -56,9 +52,6 @@ jobs:
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
Expand Down Expand Up @@ -87,3 +80,6 @@ jobs:

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2.21.8
env:
CGO_ENABLED: 0
GOFLAGS: "-tags=sync,search,scrub,metrics,lint,ui,mgmt,profile,userprefs,imagetrust,containers_image_openpgp"
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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 change: 0 additions & 1 deletion .github/workflows/dco.yml → .github/workflows/dco.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .github/workflows/dco.yml
name: DCO
on:
pull_request:
Expand Down
39 changes: 5 additions & 34 deletions .github/workflows/ecosystem-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ jobs:
name: Check client tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/clean-runner
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
cache: false
go-version: 1.20.x
- uses: ./.github/actions/clean-runner
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE
Expand Down Expand Up @@ -54,29 +53,15 @@ 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
- name: Install localstack
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
Expand All @@ -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
Loading

0 comments on commit 4ba705e

Please sign in to comment.