From a04260d16b62c64fd8905cf02cd3e1d620683f84 Mon Sep 17 00:00:00 2001 From: "bestia.dev" Date: Sun, 21 Apr 2024 21:28:51 -0500 Subject: [PATCH] 2024-04-21 --- .github/workflows/clear_all_cache.yml | 51 ++++++++++++++++++ .github/workflows/docs_pages.yml | 43 +++++++++++++++ .../workflows/rust_fmt_auto_build_test.yml | 54 +++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 .github/workflows/clear_all_cache.yml create mode 100644 .github/workflows/docs_pages.yml create mode 100644 .github/workflows/rust_fmt_auto_build_test.yml diff --git a/.github/workflows/clear_all_cache.yml b/.github/workflows/clear_all_cache.yml new file mode 100644 index 0000000..475fd5d --- /dev/null +++ b/.github/workflows/clear_all_cache.yml @@ -0,0 +1,51 @@ +name: cleanup caches on main + +# Configure Manual Trigger with workflow_dispatch +on: + workflow_dispatch: + +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + # `actions:write` permission is required to delete caches + # See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id + actions: write + contents: read + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + printf "$REPO\n" + BRANCH=main + printf "$BRANCH\n" + + # loop until the list is empty, because it deletes only 30 per page + has_items=true + while [ "$has_items" = true ] + do + printf "\033[0;33m Fetching list of cache key\n\033[0m\n" + printf "\033[0;32m gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 \n\033[0m\n" + cache_keys=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) + # printf "$cache_keys\n" + if [ -z "$cache_keys" ]; then + printf "\033[0;35m gh actions-cache list returned nothing.\n\033[0m\n" + has_items=false + fi + ## Setting this to not fail the workflow while deleting cache keys. + set +e + for cacheKey in $cache_keys + do + # printf "\033[0;32m gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm\n\033[0m\n" + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + done + printf "\033[0;33m Done\n\033[0m\n" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/docs_pages.yml b/.github/workflows/docs_pages.yml new file mode 100644 index 0000000..7ec37ea --- /dev/null +++ b/.github/workflows/docs_pages.yml @@ -0,0 +1,43 @@ +# Simple workflow for deploying static content to GitHub Pages +name: docs_pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: 'docs' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/rust_fmt_auto_build_test.yml b/.github/workflows/rust_fmt_auto_build_test.yml new file mode 100644 index 0000000..7f3da7e --- /dev/null +++ b/.github/workflows/rust_fmt_auto_build_test.yml @@ -0,0 +1,54 @@ +name: rust_fmt_auto_build_test + +on: + # push to any branch + push: + + # any pull requests + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + rust_fmt_auto_build_test: + + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: cargo fmt -- --check + run: cargo fmt -- --check + + - name: Run cache for rust dependencies + uses: Swatinem/rust-cache@v2.7.3 + + - name: Configure sccache + run: printf "RUSTC_WRAPPER=sccache\n" >> $GITHUB_ENV; printf "SCCACHE_GHA_ENABLED=true\n" >> $GITHUB_ENV + + - name: Run sccache-cache for artifacts + uses: mozilla-actions/sccache-action@v0.0.4 + + - name: install and cache cargo-auto + uses: baptiste0928/cargo-install@v3.0.0 + with: + crate: cargo-auto + + - name: Cache for automation tasks + uses: actions/cache@v4.0.0 + with: + path: | + automation_tasks_rs/.file_hashes.json + automation_tasks_rs/target + automation_tasks_rs/Cargo.toml + automation_tasks_rs/Cargo.lock + key: automation_tasks_rs + + - name: cargo auto build + run: cargo auto build + + - name: cargo auto test + run: cargo auto test +