Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(disk usage): disk related fixes and improvements #1524

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ jobs:
os: [linux, darwin]
arch: [amd64, arm64]
steps:
- name: Remove unneeded tooling
run: |
# To free up ~15 GB of disk space
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
- name: Install go
uses: actions/setup-go@v4
with:
cache: false
go-version: 1.20.x

- name: Check out source code
uses: actions/checkout@v3

- name: Cache go dependencies
id: cache-go-dependencies
uses: actions/cache@v3
Expand Down Expand Up @@ -94,6 +101,23 @@ jobs:
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: |
Expand All @@ -112,6 +136,24 @@ jobs:
AWS_SECRET_ACCESS_KEY: fake
OS: ${{ matrix.os }}
ARCH: ${{ matrix.arch }}

- 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:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ exporter-minimal: modcheck build-metadata
test: $(if $(findstring ui,$(BUILD_LABELS)), ui)
test: check-skopeo $(TESTDATA) $(ORAS)
go test -failfast -tags $(BUILD_LABELS),containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile=coverage-extended.txt -covermode=atomic ./...
rm -rf /tmp/getter*; rm -rf /tmp/trivy*
go test -failfast -tags containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile=coverage-minimal.txt -covermode=atomic ./...
rm -rf /tmp/getter*; rm -rf /tmp/trivy*
# development-mode unit tests possibly using failure injection
go test -failfast -tags dev,$(BUILD_LABELS),containers_image_openpgp -v -trimpath -race -timeout 15m -cover -coverpkg ./... -coverprofile=coverage-dev-extended.txt -covermode=atomic ./pkg/test/... ./pkg/api/... ./pkg/storage/... ./pkg/extensions/sync/... -run ^TestInject
rm -rf /tmp/getter*; rm -rf /tmp/trivy*
go test -failfast -tags dev,containers_image_openpgp -v -trimpath -race -cover -coverpkg ./... -coverprofile=coverage-dev-minimal.txt -covermode=atomic ./pkg/test/... ./pkg/storage/... ./pkg/extensions/sync/... -run ^TestInject
rm -rf /tmp/getter*; rm -rf /tmp/trivy*
go test -failfast -tags stress,$(BUILD_LABELS),containers_image_openpgp -v -trimpath -race -timeout 15m ./pkg/cli/stress_test.go

.PHONY: privileged-test
Expand Down
5 changes: 0 additions & 5 deletions pkg/api/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ func TestRoutes(t *testing.T) {
ctlr.Config.Storage.RootDirectory = t.TempDir()
ctlr.Config.Storage.Commit = true

err := test.CopyFiles("../../test/data", ctlr.Config.Storage.RootDirectory)
if err != nil {
panic(err)
}

cm := test.NewControllerManager(ctlr)
cm.StartAndWait(port)
defer cm.StopServer()
Expand Down
6 changes: 5 additions & 1 deletion pkg/extensions/extension_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ func TestTrivyDBGenerator(t *testing.T) {
},
}
storeController := storage.StoreController{
DefaultStore: mocks.MockedImageStore{},
DefaultStore: mocks.MockedImageStore{
RootDirFn: func() string {
return t.TempDir()
},
},
}

cveInfo := cveinfo.NewCVEInfo(storeController, repoDB, "ghcr.io/project-zot/trivy-db", "", logger)
Expand Down