Skip to content

Commit

Permalink
ci: Implement cleanup for jobs
Browse files Browse the repository at this point in the history
Fixes #631

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
  • Loading branch information
mudler committed Jan 10, 2022
1 parent ddeb66d commit f770fe9
Show file tree
Hide file tree
Showing 23 changed files with 791 additions and 60 deletions.
42 changes: 18 additions & 24 deletions .github/build.yaml.gomplate
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,36 @@
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
{{{- if not $config.local_runner }}}
- name: Release space from worker
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
{{{- end }}}
{{{ tmpl.Exec "runner_cleanup" }}}
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
{{{ end }}}

{{{define "prepare_build" }}}
{{{define "runner_cleanup" }}}
{{{ $config := (datasource "config") }}}
{{{- if $config.local_runner }}}
- run: |
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
{{{- else }}}
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
{{{- end }}}
{{{ end }}}

{{{define "prepare_build" }}}
{{{ $config := (datasource "config") }}}
{{{ tmpl.Exec "runner_cleanup" }}}

{{{- if $config.local_runner }}}
{{{ $arch := $config.arch }}}
Expand Down Expand Up @@ -107,11 +115,6 @@
FLAVOR: {{{ $flavor }}}
ARCH: {{{ $config.arch }}}
steps:
{{{- if $config.local_runner }}}
- run: |
sudo rm -rf build || true
sudo rm -rf bin || true
{{{- end }}}
{{{ tmpl.Exec "prepare_worker" }}}
- name: Build 🔧
shell: 'script -q -e -c "bash {0}"'
Expand Down Expand Up @@ -186,6 +189,7 @@
name: build-{{{ $flavor }}}-{{{ $config.arch }}}
path: build
if-no-files-found: error
{{{ tmpl.Exec "runner_cleanup" }}}
{{{end}}}

{{{define "build_iso"}}}
Expand Down Expand Up @@ -702,12 +706,7 @@
{{{- end }}}

steps:
{{{- if $config.local_runner }}}
- name: Cleanup
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
{{{- end }}}
{{{ tmpl.Exec "runner_cleanup" }}}
- name: Install OS deps
run: |
sudo apt-get update
Expand Down Expand Up @@ -908,11 +907,6 @@
{{{ tmpl.Exec "runner" }}}
{{{tmpl.Exec "if_with_labels" }}}
steps:
{{{- if $config.local_runner }}}
- run: |
sudo rm -rf build || true
sudo rm -rf bin || true
{{{- end }}}
{{{ tmpl.Exec "prepare_worker" }}}
{{{ tmpl.Exec "prepare_build" }}}
{{{ tmpl.Exec "make" "deps" }}}
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/build-examples-green-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ jobs:
- run: |
git fetch --prune --unshallow
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Install Go
uses: actions/setup-go@v2
with:
Expand Down Expand Up @@ -57,12 +63,18 @@ jobs:
- run: |
git fetch --prune --unshallow
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Install Go
uses: actions/setup-go@v2
with:
Expand Down Expand Up @@ -91,12 +103,18 @@ jobs:
- run: |
git fetch --prune --unshallow
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
- name: Release space from worker
if: always()
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Install Go
uses: actions/setup-go@v2
with:
Expand Down
35 changes: 33 additions & 2 deletions .github/workflows/build-master-blue-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ jobs:
# For non x86_64 archs, skip the *-fips build as there are no golang releases in other arches
SKIP_PACKAGES: "build/golang-fips toolchain-fips/yip toolchain-fips/luet-makeiso toolchain-fips/luet live/syslinux live/systemd-boot live/boot"
steps:
- run: |
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install Go
run: |
curl -L https://golang.org/dl/go1.17.5.linux-arm64.tar.gz -o go1.17.5.linux-arm64.tar.gz
Expand All @@ -39,6 +41,15 @@ jobs:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
Expand Down Expand Up @@ -82,6 +93,15 @@ jobs:
name: build-blue-arm64
path: build
if-no-files-found: error
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
image-link-blue:
runs-on: ubuntu-latest
needs: publish-blue
Expand Down Expand Up @@ -119,13 +139,15 @@ jobs:
PUBLISH_ARGS: "--plugin luet-cosign"
COSIGN_FULCIO_URL: "https://v1.fulcio.sigstore.dev"
steps:
- run: |
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install Go
run: |
curl -L https://golang.org/dl/go1.17.5.linux-arm64.tar.gz -o go1.17.5.linux-arm64.tar.gz
Expand All @@ -137,6 +159,15 @@ jobs:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
Expand Down
35 changes: 33 additions & 2 deletions .github/workflows/build-master-blue-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ jobs:
PUSH_CACHE: true
REPO_CACHE: quay.io/costoolkit/build-blue-cache
steps:
- run: |
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install Go
run: |
curl -L https://golang.org/dl/go1.17.5.linux-amd64.tar.gz -o go1.17.5.linux-amd64.tar.gz
Expand All @@ -37,6 +39,15 @@ jobs:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
Expand Down Expand Up @@ -80,6 +91,15 @@ jobs:
name: build-blue-x86_64
path: build
if-no-files-found: error
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
image-link-blue:
runs-on: ubuntu-latest
needs: publish-blue
Expand Down Expand Up @@ -117,13 +137,15 @@ jobs:
PUBLISH_ARGS: "--plugin luet-cosign"
COSIGN_FULCIO_URL: "https://v1.fulcio.sigstore.dev"
steps:
- run: |
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install Go
run: |
curl -L https://golang.org/dl/go1.17.5.linux-amd64.tar.gz -o go1.17.5.linux-amd64.tar.gz
Expand All @@ -135,6 +157,15 @@ jobs:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- if: always()
run: |
sudo rm -rf build || true
sudo rm -rf bin || true
sudo rm /usr/bin/luet || true
sudo rm -Rf /etc/luet/ || true
sudo rm -Rf /var/tmp/luet || true
sudo rm -Rf /var/luet || true
docker system prune -f -a --volumes || true
- name: Install CI plugins
run: |
sudo cp -rfv .github/plugins/* /usr/bin/
Expand Down
Loading

0 comments on commit f770fe9

Please sign in to comment.