Skip to content

Commit

Permalink
Merge branch 'apache:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
freakishness committed Feb 7, 2024
2 parents a150fd8 + 888dc22 commit c104238
Show file tree
Hide file tree
Showing 4,484 changed files with 310,698 additions and 158,591 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
248 changes: 248 additions & 0 deletions .github/actions/free-disk-space/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
name: "Free Disk Space (Ubuntu)"
author: "Jérémie Lumbroso"
description: "A configurable GitHub Action to free up disk space on an Ubuntu GitHub Actions runner.(https://github.com/jlumbroso/free-disk-space)"

# See: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding
branding:
icon: "trash-2"
color: "green"

inputs:
android:
description: "Remove Android runtime"
required: false
default: "true"
dotnet:
description: "Remove .NET runtime"
required: false
default: "true"
haskell:
description: "Remove Haskell runtime"
required: false
default: "true"

# option inspired by:
# https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
large-packages:
description: "Remove large packages"
required: false
default: "true"

docker-images:
description: "Remove Docker images"
required: false
default: "true"

# option inspired by:
# https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
tool-cache:
description: "Remove image tool cache"
required: false
default: "false"

swap-storage:
description: "Remove swap storage"
required: false
default: "true"

runs:
using: "composite"
steps:
- shell: bash
run: |
# ======
# MACROS
# ======
# macro to print a line of equals
# (silly but works)
printSeparationLine() {
str=${1:=}
num=${2:-80}
counter=1
output=""
while [ $counter -le $num ]
do
output="${output}${str}"
counter=$((counter+1))
done
echo "${output}"
}
# macro to compute available space
# REF: https://unix.stackexchange.com/a/42049/60849
# REF: https://stackoverflow.com/a/450821/408734
getAvailableSpace() { echo $(df -a $1 | awk 'NR > 1 {avail+=$4} END {print avail}'); }
# macro to make Kb human readable (assume the input is Kb)
# REF: https://unix.stackexchange.com/a/44087/60849
formatByteCount() { echo $(numfmt --to=iec-i --suffix=B --padding=7 $1'000'); }
# macro to output saved space
printSavedSpace() {
saved=${1}
title=${2:-}
echo ""
printSeparationLine '*' 80
if [ ! -z "${title}" ]; then
echo "=> ${title}: Saved $(formatByteCount $saved)"
else
echo "=> Saved $(formatByteCount $saved)"
fi
printSeparationLine '*' 80
echo ""
}
# macro to print output of dh with caption
printDH() {
caption=${1:-}
printSeparationLine '=' 80
echo "${caption}"
echo ""
echo "$ dh -h /"
echo ""
df -h /
echo "$ dh -a /"
echo ""
df -a /
echo "$ dh -a"
echo ""
df -a
printSeparationLine '=' 80
}
# ======
# SCRIPT
# ======
# Display initial disk space stats
AVAILABLE_INITIAL=$(getAvailableSpace)
AVAILABLE_ROOT_INITIAL=$(getAvailableSpace '/')
printDH "BEFORE CLEAN-UP:"
echo ""
# Option: Remove Android library
if [[ ${{ inputs.android }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
sudo rm -rf /usr/local/lib/android || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Android library"
fi
# Option: Remove .NET runtime
if [[ ${{ inputs.dotnet }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
# https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11
sudo rm -rf /usr/share/dotnet || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED ".NET runtime"
fi
# Option: Remove Haskell runtime
if [[ ${{ inputs.haskell }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Haskell runtime"
fi
# Option: Remove large packages
# REF: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
if [[ ${{ inputs.large-packages }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Large misc. packages"
fi
# Option: Remove Docker images
if [[ ${{ inputs.docker-images }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
sudo docker image prune --all --force || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Docker images"
fi
# Option: Remove tool cache
# REF: https://github.com/actions/virtual-environments/issues/2875#issuecomment-1163392159
if [[ ${{ inputs.tool-cache }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Tool cache"
fi
# Option: Remove Swap storage
if [[ ${{ inputs.swap-storage }} == 'true' ]]; then
BEFORE=$(getAvailableSpace)
sudo swapoff -a || true
sudo rm -f /mnt/swapfile || true
free -h
AFTER=$(getAvailableSpace)
SAVED=$((AFTER-BEFORE))
printSavedSpace $SAVED "Swap storage"
fi
# Output saved space statistic
AVAILABLE_END=$(getAvailableSpace)
AVAILABLE_ROOT_END=$(getAvailableSpace '/')
echo ""
printDH "AFTER CLEAN-UP:"
echo ""
echo ""
echo "/dev/root:"
printSavedSpace $((AVAILABLE_ROOT_END - AVAILABLE_ROOT_INITIAL))
echo "overall:"
printSavedSpace $((AVAILABLE_END - AVAILABLE_INITIAL))
72 changes: 70 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:

- name: Restore Tools Cache
id: cache-tools
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: ${{ runner.os }}-cache-tools
with:
Expand All @@ -204,7 +204,7 @@ jobs:

# Released version of Cython has issues with Python 11. Set runner to use Python 3.10
# https://github.com/cython/cython/issues/4500
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Run Builds
Expand All @@ -219,3 +219,71 @@ jobs:
name: macos-builds
path: buildartifacts/
continue-on-error: true

msys2:
needs: Fetch-Source
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
boards: [msys2]

defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: MSYS
update: false
install: >-
base-devel
gcc
gperf
automake
autoconf
git
python3
ncurses-devel
unzip
zip
tio
zlib-devel
cmake
ninja
python-pip
vim
- name: pip3 install
run: |
pip3 install --root-user-action=ignore --no-cache-dir pyelftools cxxfilt kconfiglib
- run: git config --global core.autocrlf false

- name: Download Source Artifact
uses: actions/download-artifact@v3
with:
name: source-bundle
path: .

- name: Extract sources
run: tar zxf sources.tar.gz

- name: Export NuttX Repo SHA
run: echo "nuttx_sha=`git -C sources/nuttx rev-parse HEAD`" >> $GITHUB_ENV

- name: Run Builds
run: |
echo "::add-matcher::sources/nuttx/.github/gcc.json"
export ARTIFACTDIR=`pwd`/buildartifacts
git config --global --add safe.directory /github/workspace/sources/nuttx
git config --global --add safe.directory /github/workspace/sources/apps
cd sources/nuttx/tools/ci
./cibuild.sh -g -i -A -C -R testlist/${{matrix.boards}}.dat
- uses: actions/upload-artifact@v3
with:
name: msys2-builds
path: buildartifacts/
continue-on-error: true
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install LaTeX packages
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/docker_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Free Disk Space (Ubuntu)
uses: ./.github/actions/free-disk-space
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -57,11 +73,6 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Free Up Extra Disk Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/gch
- name: Pre-build Disk Stats
run: |
df -h
Expand Down
Loading

0 comments on commit c104238

Please sign in to comment.