Skip to content

Commit

Permalink
ci(disk usage): disk related fixes and improvements
Browse files Browse the repository at this point in the history
ci(workflow): show disk usage and free up disk space used by unneeded tooling
ci(tests): routes tests: do not copy large images if they are not used later
ci(trivy): update a test: download trivy.db to a temporary folder

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
  • Loading branch information
andaaron committed Jun 15, 2023
1 parent 988ca42 commit d5a8927
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
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

0 comments on commit d5a8927

Please sign in to comment.