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

Clean-up runner #27504

Merged
merged 4 commits into from
Feb 2, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/actions/cleanup-runner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# action.yml
name: 'Cleanup Runner'
description: 'Cleans up runner resources'
author: 'victoralfaro-dotcms'
runs:
using: 'composite'
steps:
- name: Show Disk Usage
shell: bash
run: |
echo '# df -h'
df -h

echo '# docker images'
docker images || true

echo '# du -sh /home/runner'
sudo du -sh /home/runner || true

- name: Clean apt cache
shell: bash
run: |
echo 'Clean apt cache'
time sudo apt-get clean -y
time sudo apt-get autoclean -y
time sudo apt-get autoremove -y
time sudo rm -rf /var/lib/apt/lists/*

- name: Cleanup Docker
shell: bash
run: |
echo 'Cleanup Docker'
time docker system prune -f
time docker volume prune -f
time docker image prune -f
time docker container prune -f
time docker network prune -f

- name: Reclaim Disk Space
shell: bash
run: |
removeIfExists() {
local file=$1
[[ -e $file ]] && time sudo rm -rf $1 || true
}

removeIfExists /usr/share/dotnet
removeIfExists /usr/share/swift
removeIfExists /usr/local/lib/android
removeIfExists /opt/ghc
removeIfExists /opt/pipx

removeIfExists /opt/hostedtoolcache/CodeQL
removeIfExists /imagegeneration/installers/go-*
removeIfExists /imagegeneration/installers/node-*
removeIfExists /imagegeneration/installers/python-*

removeIfExists /home/runner/work/_temp/*
removeIfExists /home/runner/work/_tool/*
removeIfExists /home/runner/work/_config/*

- name: Show Disk Usage
shell: bash
run: |
echo "# df -h"
df -h

echo '# docker images'
docker images || true

echo '# du -sh /home/runner'
sudo du -sh /home/runner || true
37 changes: 15 additions & 22 deletions .github/workflows/maven-cicd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/cleanup-runner
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -232,7 +233,8 @@ jobs:
maven_args: ""
}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/cleanup-runner
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -292,7 +294,8 @@ jobs:
maven_args: ""
}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/cleanup-runner
- name: Set up JDK ${{ matrix.java.name }}
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -360,10 +363,8 @@ jobs:
env:
MAVEN_OPTS: -Xmx2048m
steps:
- uses: actions/checkout@v3
- name: apt clean
shell: bash
run: sudo apt-get clean
- uses: actions/checkout@v4
- uses: ./.github/actions/cleanup-runner
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -471,10 +472,8 @@ jobs:
maven_args: '"-Dit.test=MainSuite2b" -Dit.test.forkcount=1'
}
steps:
- uses: actions/checkout@v3
- name: apt clean
shell: bash
run: sudo apt-get clean
- uses: actions/checkout@v4
- uses: ./.github/actions/cleanup-runner
- name: Set up IT Tests ${{ matrix.java.name }} ${{ matrix.suites.name }}
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -534,9 +533,8 @@ jobs:
matrix:
collection_group: [ 'category-container', 'content', 'experiment', 'graphql', 'page', 'pp', 'template', 'workflow', 'default' ]
steps:
- id: fetch-core
name: Fetch Core Repo
uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/cleanup-runner
- run: sudo npm install --location=global newman@5.3.2 newman-reporter-htmlextra@1.23.0
- id: docker-login
name: Login to GHCR
Expand Down Expand Up @@ -604,12 +602,10 @@ jobs:
runs-on: ubuntu-latest
needs: [build-jdk11]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: apt clean
shell: bash
run: sudo apt-get clean
- uses: ./.github/actions/cleanup-runner
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -647,10 +643,7 @@ jobs:
needs: linux-postman-tests
if: (success() || failure()) && (github.repository == 'dotCMS/core' || !endsWith(github.ref, '/master'))
steps:
- id: fetch-core
name: Fetch Core Repo
uses: actions/checkout@v3

- uses: actions/checkout@v4
- id: cleanup-package
name: Clean up CICD packages
uses: ./.github/actions/cleanup-gh-packages
Expand Down