diff --git a/.github/workflows/clean-up-cache-cron.yml b/.github/workflows/clean-up-cache-cron.yml new file mode 100644 index 00000000000..8c311853d06 --- /dev/null +++ b/.github/workflows/clean-up-cache-cron.yml @@ -0,0 +1,56 @@ +name: Cleanup Caches by Cron + +on: + schedule: + - cron: '0 3 * * *' # Runs daily at 03:00 UTC + workflow_dispatch: # Allows manual triggering if needed + +permissions: + contents: write + + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Set Up GitHub CLI + run: | + sudo apt-get update && sudo apt-get install -y gh + gh extension install actions/gh-actions-cache || echo "Extension already installed" + + - name: Cleanup Caches + env: + GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} + run: | + REPO=${{ github.repository }} + BRANCH="master" # Only focus on the master branch + + echo "Fetching list of cache keys for branch: $BRANCH" + cacheKeysForMaster=$(gh actions-cache list -R $REPO -B $BRANCH --json key | jq -r '.[].key') + + if [ -z "$cacheKeysForMaster" ]; then + echo "No caches found for branch: $BRANCH" + exit 0 + fi + + echo "Deleting caches..." + for cacheKey in $cacheKeysForMaster; do + echo "Deleting cache: $cacheKey" + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Cleanup completed." + + - name: Verify Remaining Caches + run: | + echo "Checking for remaining caches in branch: $BRANCH" + remainingCaches=$(gh actions-cache list -R ${{ github.repository }} -B $BRANCH --json key | jq -r '.[].key') + + if [ -z "$remainingCaches" ]; then + echo "All caches successfully cleared." + else + echo "Remaining caches detected:" + echo "$remainingCaches" + exit 1 + fi + env: + GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/clean-up-cache.yml b/.github/workflows/clean-up-cache.yml index 08ac5bacfb8..47617237077 100644 --- a/.github/workflows/clean-up-cache.yml +++ b/.github/workflows/clean-up-cache.yml @@ -1,4 +1,4 @@ -name: cleanup caches by a branch +name: Cleanup Caches by Branch on: pull_request: types: @@ -14,20 +14,52 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 - - name: Cleanup + - name: Setup GitHub CLI + run: | + # Ensure the latest version of GitHub CLI is installed + sudo apt-get update && sudo apt-get install -y gh + # Install the actions-cache extension + gh extension install actions/gh-actions-cache || echo "Extension already installed" + + - name: Check Token Permissions + run: gh auth status + env: + GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} + + - name: Cleanup Caches run: | - gh extension install actions/gh-actions-cache REPO=${{ github.repository }} + # Adjust branch reference if necessary BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" - echo "Fetching list of cache key" - cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) - ## Setting this to not fail the workflow while deleting cache keys. - set +e + + echo "Fetching list of cache keys for branch: $BRANCH" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH --json key | jq -r '.[].key') + + if [ -z "$cacheKeysForPR" ]; then + echo "No caches found for branch: $BRANCH" + exit 0 + fi + echo "Deleting caches..." - for cacheKey in $cacheKeysForPR - do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + for cacheKey in $cacheKeysForPR; do + echo "Deleting cache: $cacheKey" + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm done - echo "Done" + echo "Cleanup completed." + env: + GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} + + - name: Verify Remaining Caches + run: | + echo "Checking for remaining caches in branch: $BRANCH" + remainingCaches=$(gh actions-cache list -R ${{ github.repository }} -B $BRANCH --json key | jq -r '.[].key') + + if [ -z "$remainingCaches" ]; then + echo "All caches successfully cleared." + else + echo "Remaining caches detected:" + echo "$remainingCaches" + exit 1 + fi env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/of.yml b/.github/workflows/of.yml index 0188bb4be6a..94c3207e23d 100644 --- a/.github/workflows/of.yml +++ b/.github/workflows/of.yml @@ -33,19 +33,19 @@ jobs: - uses: actions/checkout@v4 - name: Docker Step run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.74 bash" - - name: Determine Release - id: vars - shell: bash - run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then - echo "RELEASE=nightly" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then - echo "RELEASE=latest" >> $GITHUB_ENV - else - echo "RELEASE=latest" >> $GITHUB_ENV - fi + # - name: Determine Release + # id: vars + # shell: bash + # run: | + # if [[ "${{ github.ref }}" == refs/tags/* ]]; then + # echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + # echo "RELEASE=nightly" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then + # echo "RELEASE=latest" >> $GITHUB_ENV + # else + # echo "RELEASE=latest" >> $GITHUB_ENV + # fi - name: Download libs run: ./scripts/$TARGET/download_libs.sh -t $RELEASE - name: Install dependencies @@ -131,19 +131,19 @@ jobs: install: >- git unzip - - name: Determine Release - id: vars - shell: bash - run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then - echo "RELEASE=nightly" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then - echo "RELEASE=latest" >> $GITHUB_ENV - else - echo "RELEASE=latest" >> $GITHUB_ENV - fi + # - name: Determine Release + # id: vars + # shell: bash + # run: | + # if [[ "${{ github.ref }}" == refs/tags/* ]]; then + # echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + # echo "RELEASE=nightly" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then + # echo "RELEASE=latest" >> $GITHUB_ENV + # else + # echo "RELEASE=latest" >> $GITHUB_ENV + # fi - name: Install dependencies shell: msys2 {0} run: ./scripts/ci/vs/install.sh @@ -257,19 +257,19 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2.14 with: key: ${{ matrix.cfg.libs }} - - name: Determine Release - id: vars - shell: bash - run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then - echo "RELEASE=nightly" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then - echo "RELEASE=latest" >> $GITHUB_ENV - else - echo "RELEASE=latest" >> $GITHUB_ENV - fi + # - name: Determine Release + # id: vars + # shell: bash + # run: | + # if [[ "${{ github.ref }}" == refs/tags/* ]]; then + # echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + # echo "RELEASE=nightly" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then + # echo "RELEASE=latest" >> $GITHUB_ENV + # else + # echo "RELEASE=latest" >> $GITHUB_ENV + # fi - name: Download libs run: ./scripts/linux/download_libs.sh -t $RELEASE -a ${{matrix.cfg.libs}} - name: Install dependencies @@ -297,19 +297,19 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2.14 with: key: ${{ matrix.cfg.target }}-${{ matrix.cfg.libs }} - - name: Determine Release - id: vars - shell: bash - run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then - echo "RELEASE=nightly" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then - echo "RELEASE=latest" >> $GITHUB_ENV - else - echo "RELEASE=latest" >> $GITHUB_ENV - fi + # - name: Determine Release + # id: vars + # shell: bash + # run: | + # if [[ "${{ github.ref }}" == refs/tags/* ]]; then + # echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + # echo "RELEASE=nightly" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then + # echo "RELEASE=latest" >> $GITHUB_ENV + # else + # echo "RELEASE=latest" >> $GITHUB_ENV + # fi - name: Download libs run: ./scripts/${{matrix.cfg.libs}}/download_libs.sh -t $RELEASE - name: install @@ -340,19 +340,19 @@ jobs: with: packages: aptitude aptitude-common libboost-iostreams1.83.0 libcwidget4 libsigc++-2.0-0v5 libxapian30 fonts-wine{a} libasound2-plugins{a} libcapi20-3t64{a} libosmesa6{a} libpcsclite1{a} libspeexdsp1{a} libwine{a} libxkbregistry0{a} libz-mingw-w64{a} wine{a} wine64 wget2 make libjack-jackd2-0 libjack-jackd2-dev freeglut3-dev libasound2-dev libxmu-dev libxxf86vm-dev g++ libgl1-mesa-dev libglu1-mesa-dev libraw1394-dev libudev-dev libdrm-dev libglew-dev libopenal-dev libsndfile1-dev libfreeimage-dev libcairo2-dev libfreetype6-dev libpulse-dev libusb-1.0-0-dev libgtk2.0-dev libopencv-dev libassimp-dev librtaudio-dev gdb libglfw3-dev liburiparser-dev libpugixml-dev libgconf-2-4 libgtk2.0-0 libpoco-dev libxcursor-dev libxi-dev libxinerama-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav gstreamer1.0-pulseaudio gstreamer1.0-x gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-plugins-base gstreamer1.0-plugins-good version: 1.0 - - name: Determine Release - id: vars - shell: bash - run: | - if [[ "${{ github.ref }}" == refs/tags/* ]]; then - echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then - echo "RELEASE=nightly" >> $GITHUB_ENV - elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then - echo "RELEASE=latest" >> $GITHUB_ENV - else - echo "RELEASE=latest" >> $GITHUB_ENV - fi + # - name: Determine Release + # id: vars + # shell: bash + # run: | + # if [[ "${{ github.ref }}" == refs/tags/* ]]; then + # echo "RELEASE=${{ github.ref_name }}" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + # echo "RELEASE=nightly" >> $GITHUB_ENV + # elif [[ "${{ github.ref }}" == "refs/heads/bleeding" ]]; then + # echo "RELEASE=latest" >> $GITHUB_ENV + # else + # echo "RELEASE=latest" >> $GITHUB_ENV + # fi - uses: actions/checkout@v4 - name: ccache uses: hendrikmuhs/ccache-action@v1.2.14