Files
zot/.github/workflows/test.yaml
T
Andrei Aaron 5e57656bff GCS storage support (#3798)
feat(storage): add a GCS driver

test(storage): add unit tests for GCS driver

test(storage): add missing unit tests for GCS driver & resolve lint issues

fix: configuration validation for GCS Storage

test(storage): resolve panic by test due to setupGCS ignoring returned error

test(storage): add dummy gcs credentials

test: add darwin support for macos to run tests

ci: update workflows to pin gcs emulator version

lint: resolve long line lengths & formatting issues

test: move error for gcs mock earlier with an error

test: stop test using local google credentials and use mock instead

test: add missing dummy creds

test(storage): use storage-testbench for GCS, isolate GCS tests, fix driver Delete

- Switch GCS emulator from fake-gcs-server to storage-testbench in CI.
  Run the GCS emulator only in the privileged-test job; remove it from
  minimal and extended test jobs.

- Consolidate GCS tests under pkg/storage/gcs (needprivileges,linux).
  Add TestMain with HTTPS proxy and /etc/hosts so tests talk to
  storage-testbench; move GCS-specific cases from storage_test.go and
  scrub_test.go into gcs_test.go. Run GCS tests via a second privileged-test
  invocation and collect coverage in coverage-needprivileges-gcs.txt.

- Make GCS driver Delete idempotent and normalize errors. Treat
  PathNotFoundError from Delete as success so that deleting an already-gone
  path (e.g. after GC under eventual consistency) does not fail. Add
  formatErr to map 404/not found to PathNotFoundError and use it for all
  driver methods so callers get consistent storage driver errors.

- Drop GCS branches and helpers from storage_test.go and scrub_test.go so
  non-privileged tests only use local/S3; GCS is tested only in
  pkg/storage/gcs with storage-testbench.

- Set GCSMOCK_ENDPOINT without /storage/v1/, as the rest of the URL is set in tests.

- Show errors in case of failure to create bucket.

- Consolidate StorageDriverMock structs inside the pkg/test/mocks package.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
Co-authored-by: Steven Marks <steve.marks@qomodo.io>
2026-02-18 23:41:21 -08:00

202 lines
6.1 KiB
YAML

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@v6
- name: Install go
uses: actions/setup-go@v6
with:
cache: false
check-latest: true
go-version: 1.25.x
- name: Cache go dependencies
id: cache-go-dependencies
uses: actions/cache@v5
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
- 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@v6
with:
name: coverage-minimal
path: coverage-minimal.txt
- uses: ./.github/actions/teardown-localstack
test-run-extensions:
name: Run zot with extensions tests
runs-on: oracle-vm-16cpu-64gb-x86-64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
cache: false
check-latest: true
go-version: 1.25.x
- name: Cache go dependencies
id: cache-go-dependencies
uses: actions/cache@v5
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
- 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@v6
with:
name: coverage-extended
path: coverage-extended.txt
- uses: ./.github/actions/teardown-localstack
test-run-devmode:
name: Running development-mode tests on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
cache: false
check-latest: true
go-version: 1.25.x
- name: Cache go dependencies
id: cache-go-dependencies
uses: actions/cache@v5
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: run zot development-mode unit tests (possibly using failure injection)
run: make test-devmode
- name: upload coverage
uses: actions/upload-artifact@v6
with:
name: coverage-devmode
path: coverage-dev-*.txt
test-run-privileged:
name: Running privileged tests on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
cache: false
check-latest: true
go-version: 1.25.x
- name: Cache go dependencies
id: cache-go-dependencies
uses: actions/cache@v5
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-gcs-storage-testbench
- name: run zot privileged tests
run: >
sudo env
"PATH=$PATH"
"GCSMOCK_ENDPOINT=$GCSMOCK_ENDPOINT"
"STORAGE_EMULATOR_HOST=$STORAGE_EMULATOR_HOST"
make privileged-test
env:
GCSMOCK_ENDPOINT: http://localhost:9000/
STORAGE_EMULATOR_HOST: localhost:9000
- name: upload coverage
uses: actions/upload-artifact@v6
with:
name: coverage-needprivileges
path: coverage-needprivileges-*.txt
- uses: ./.github/actions/teardown-gcs-storage-testbench
test-coverage:
name: Collect all test coverage
runs-on: ubuntu-latest
if: always()
needs: [test-run-minimal,test-run-extensions,test-run-devmode,test-run-privileged]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
cache: false
check-latest: true
go-version: 1.25.x
- name: download all workflow coverage files
uses: actions/download-artifact@v7
- name: merge code coverage
run: |
cd $GITHUB_WORKSPACE
cp coverage-minimal/* .
cp coverage-extended/* .
cp coverage-devmode/* .
cp coverage-needprivileges/* .
make covhtml
mkdir unified-coverage
cp coverage.txt coverage.html unified-coverage/
- name: upload unified-coverage as build artifact
uses: actions/upload-artifact@v6
with:
name: unified-coverage
path: unified-coverage/*
- name: upload code coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}