From 47e7db4c5cf7da27f9ce098636c0f7f7a54b2894 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Tue, 8 Apr 2025 12:55:09 -0600 Subject: [PATCH] Update to ubuntu-24.02 or ubuntu-latest, apply auto formatting with lsp --- .github/actions/discord-send/action.yml | 38 ++--- .github/actions/setup/action.yml | 170 ++++++++++----------- .github/actions/sync-repository/action.yml | 20 +-- .github/workflows/pr-labels.yml | 6 +- .github/workflows/pr.yml | 83 +++++----- .github/workflows/stable.yml | 90 +++++------ .github/workflows/testing.yml | 64 ++++---- 7 files changed, 235 insertions(+), 236 deletions(-) diff --git a/.github/actions/discord-send/action.yml b/.github/actions/discord-send/action.yml index db4a8e3a2..2a7197643 100644 --- a/.github/actions/discord-send/action.yml +++ b/.github/actions/discord-send/action.yml @@ -30,22 +30,22 @@ runs: MSG_COLOR: ${{ inputs.color }} MSG_VALUE: ${{ inputs.message }} run: | - payload="$(jq --null-input --compact-output --monochrome-output \ - --arg title "$MSG_TITLE" \ - --arg link "$MSG_LINK" \ - --arg color "$MSG_COLOR" \ - --arg message "$MSG_VALUE" \ - '{ - username: "Toltec", - avatar_url: "https://avatars0.githubusercontent.com/u/71158884", - embeds: [{ - title: $title, - url: $link, - color: $color, - description: $message, - }] - }')" - curl --silent --show-error --fail \ - --header "Content-Type: application/json" \ - --data "$payload" \ - 'https://discord.com/api/webhooks/${{ inputs.channel }}/${{ inputs.token }}' + payload="$(jq --null-input --compact-output --monochrome-output \ + --arg title "$MSG_TITLE" \ + --arg link "$MSG_LINK" \ + --arg color "$MSG_COLOR" \ + --arg message "$MSG_VALUE" \ + '{ + username: "Toltec", + avatar_url: "https://avatars0.githubusercontent.com/u/71158884", + embeds: [{ + title: $title, + url: $link, + color: $color, + description: $message, + }] + }')" + curl --silent --show-error --fail \ + --header "Content-Type: application/json" \ + --data "$payload" \ + 'https://discord.com/api/webhooks/${{ inputs.channel }}/${{ inputs.token }}' diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 3e34d796a..e582b43e6 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,87 +1,87 @@ name: Setup Toltec dependencies runs: - using: "composite" - steps: - - name: Check for Apt updates - shell: bash - run: | - sudo apt-get update -yq - echo "aptVersion=libarchive-tools-$(apt-cache policy libarchive-tools | grep -oP '(?<=Candidate:\s)(.+)')" >> $GITHUB_ENV - - name: Cache Apt packages - uses: actions/cache@v4 - id: cache-apt - with: - path: ~/.aptcache - key: ${{ env.aptVersion }} - - name: Install or restore Apt packages - shell: bash - env: - CACHE_HIT: ${{ steps.cache-apt.outputs.cache-hit }} - run: | - if [[ "$CACHE_HIT" != 'true' ]]; then - sudo apt-get install -yq libarchive-tools - mkdir -p ~/.aptcache - sudo dpkg -L libarchive-tools | while IFS= read -r f; do if test -f $f; then echo $f; fi; done | xargs cp --parents --target-directory ~/.aptcache/ - else - sudo cp --verbose --force --recursive ~/.aptcache/* / - fi - - name: Cache shfmt - uses: actions/cache@v4 - with: - path: /usr/local/bin/shfmt - key: 43439b996942b53dfafa9b6ff084f394555d049c98fb7ec37978f7668b43e1be - - name: Install shfmt - shell: bash - run: | - install_dir=/usr/local/bin - if ! [[ -f "$install_dir"/shfmt ]]; then - shfmt_version=v3.2.1 - shfmt_checksum=43439b996942b53dfafa9b6ff084f394555d049c98fb7ec37978f7668b43e1be - sudo curl --location --silent --fail --tlsv1.2 --proto '=https' \ - --output "$install_dir"/shfmt \ - https://github.com/mvdan/sh/releases/download/"$shfmt_version"/shfmt_"$shfmt_version"_linux_amd64 - sha256sum -c <(echo "$shfmt_checksum $install_dir/shfmt") > /dev/null 2>&1 - sudo chmod a+x "$install_dir"/shfmt - fi - - name: Cache Shellcheck - uses: actions/cache@v4 - with: - path: /usr/local/bin/shellcheck - key: 64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 - - name: Install Shellcheck - shell: bash - run: | - install_dir=/usr/local/bin - if ! [[ -f "$install_dir"/shellcheck ]];then - shellcheck_version=v0.7.1 - shellcheck_checksum=64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 - shellcheck_arname=shellcheck.tar.xz - curl --location --silent --fail --tlsv1.2 --proto '=https' \ - --output "$shellcheck_arname" \ - https://github.com/koalaman/shellcheck/releases/download/"$shellcheck_version"/shellcheck-"$shellcheck_version".linux.x86_64.tar.xz - sha256sum -c <(echo "$shellcheck_checksum $shellcheck_arname") > /dev/null 2>&1 - tar -xf "$shellcheck_arname" --strip-components=1 \ - shellcheck-"$shellcheck_version"/shellcheck - rm "$shellcheck_arname" - chmod a+x shellcheck - sudo chown root:root shellcheck - sudo mv shellcheck "$install_dir" - fi - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Cache Python environment - uses: actions/cache@v4 - id: cache-python - with: - path: .venv - key: .venv-${{ hashFiles('requirements.txt') }} - - name: Install Python dependencies - shell: bash - env: - CACHE_HIT: ${{ steps.cache-python.outputs.cache-hit }} - run: | - if [[ "$CACHE_HIT" != 'true' ]]; then - make .venv/bin/activate - fi + using: "composite" + steps: + - name: Check for Apt updates + shell: bash + run: | + sudo apt-get update -yq + echo "aptVersion=libarchive-tools-$(apt-cache policy libarchive-tools | grep -oP '(?<=Candidate:\s)(.+)')" >> $GITHUB_ENV + - name: Cache Apt packages + uses: actions/cache@v4 + id: cache-apt + with: + path: ~/.aptcache + key: ${{ env.aptVersion }} + - name: Install or restore Apt packages + shell: bash + env: + CACHE_HIT: ${{ steps.cache-apt.outputs.cache-hit }} + run: | + if [[ "$CACHE_HIT" != 'true' ]]; then + sudo apt-get install -yq libarchive-tools + mkdir -p ~/.aptcache + sudo dpkg -L libarchive-tools | while IFS= read -r f; do if test -f $f; then echo $f; fi; done | xargs cp --parents --target-directory ~/.aptcache/ + else + sudo cp --verbose --force --recursive ~/.aptcache/* / + fi + - name: Cache shfmt + uses: actions/cache@v4 + with: + path: /usr/local/bin/shfmt + key: 43439b996942b53dfafa9b6ff084f394555d049c98fb7ec37978f7668b43e1be + - name: Install shfmt + shell: bash + run: | + install_dir=/usr/local/bin + if ! [[ -f "$install_dir"/shfmt ]]; then + shfmt_version=v3.2.1 + shfmt_checksum=43439b996942b53dfafa9b6ff084f394555d049c98fb7ec37978f7668b43e1be + sudo curl --location --silent --fail --tlsv1.2 --proto '=https' \ + --output "$install_dir"/shfmt \ + https://github.com/mvdan/sh/releases/download/"$shfmt_version"/shfmt_"$shfmt_version"_linux_amd64 + sha256sum -c <(echo "$shfmt_checksum $install_dir/shfmt") > /dev/null 2>&1 + sudo chmod a+x "$install_dir"/shfmt + fi + - name: Cache Shellcheck + uses: actions/cache@v4 + with: + path: /usr/local/bin/shellcheck + key: 64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 + - name: Install Shellcheck + shell: bash + run: | + install_dir=/usr/local/bin + if ! [[ -f "$install_dir"/shellcheck ]];then + shellcheck_version=v0.7.1 + shellcheck_checksum=64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 + shellcheck_arname=shellcheck.tar.xz + curl --location --silent --fail --tlsv1.2 --proto '=https' \ + --output "$shellcheck_arname" \ + https://github.com/koalaman/shellcheck/releases/download/"$shellcheck_version"/shellcheck-"$shellcheck_version".linux.x86_64.tar.xz + sha256sum -c <(echo "$shellcheck_checksum $shellcheck_arname") > /dev/null 2>&1 + tar -xf "$shellcheck_arname" --strip-components=1 \ + shellcheck-"$shellcheck_version"/shellcheck + rm "$shellcheck_arname" + chmod a+x shellcheck + sudo chown root:root shellcheck + sudo mv shellcheck "$install_dir" + fi + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Cache Python environment + uses: actions/cache@v4 + id: cache-python + with: + path: .venv + key: .venv-${{ hashFiles('requirements.txt') }} + - name: Install Python dependencies + shell: bash + env: + CACHE_HIT: ${{ steps.cache-python.outputs.cache-hit }} + run: | + if [[ "$CACHE_HIT" != 'true' ]]; then + make .venv/bin/activate + fi diff --git a/.github/actions/sync-repository/action.yml b/.github/actions/sync-repository/action.yml index 01b7aa50a..0f3f7f3f7 100644 --- a/.github/actions/sync-repository/action.yml +++ b/.github/actions/sync-repository/action.yml @@ -23,13 +23,13 @@ runs: - name: rsync packages and index shell: bash run: | - mkdir -p private - chmod 700 private - echo '${{ inputs.ssh-key }}' > private/id_rsa - echo '${{ inputs.ssh-known-hosts }}' > private/known_hosts - chmod 600 private/* - rsync --archive --verbose --compress --delete --hard-links \ - -e "ssh -p ${{ inputs.ssh-port }} -i private/id_rsa -o UserKnownHostsFile=private/known_hosts" \ - '${{ inputs.local-path }}' \ - '${{ inputs.remote-path }}' - rm -r private + mkdir -p private + chmod 700 private + echo '${{ inputs.ssh-key }}' > private/id_rsa + echo '${{ inputs.ssh-known-hosts }}' > private/known_hosts + chmod 600 private/* + rsync --archive --verbose --compress --delete --hard-links \ + -e "ssh -p ${{ inputs.ssh-port }} -i private/id_rsa -o UserKnownHostsFile=private/known_hosts" \ + '${{ inputs.local-path }}' \ + '${{ inputs.remote-path }}' + rm -r private diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml index 166d3e256..a38b5098d 100644 --- a/.github/workflows/pr-labels.yml +++ b/.github/workflows/pr-labels.yml @@ -5,9 +5,9 @@ on: jobs: check-labels: name: Check that PRs against the stable branch are labelled correctly - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Check labels run: | - [[ '${{ github.base_ref }}' != stable ]] \ - || [[ '${{ contains(github.event.pull_request.labels.*.name, 'merge') }}' == true ]] + [[ '${{ github.base_ref }}' != stable ]] \ + || [[ '${{ contains(github.event.pull_request.labels.*.name, 'merge') }}' == true ]] diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c6b30ff9b..c8b71ee37 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,44 +1,43 @@ name: pr -on: - pull_request +on: pull_request jobs: - lint: - name: Check that it conforms to the style guide - runs-on: ubuntu-22.04 - steps: - - name: Checkout the Git repository - uses: actions/checkout@v4 - - name: Setup Toltec dependencies - uses: ./.github/actions/setup - - name: Check formatting - run: make format - - name: Check for erroneous constructs - run: make lint - pr: - name: Check that it builds without error - runs-on: ubuntu-22.04 - needs: lint - steps: - - name: Checkout the Git repository - uses: actions/checkout@v4 - - name: Setup Toltec dependencies - uses: ./.github/actions/setup - - name: Build packages - run: FLAGS='--remote-repo https://toltec-dev.org/${{ github.base_ref }}' make repo-new - - name: Save the build output - uses: actions/upload-artifact@v4 - with: - name: repo - path: build/repo - - name: Build packages for experimental - if: ${{ contains(github.event.pull_request.labels.*.name, 'experimental') }} - run: make repo FLAGS='--remote-repo https://toltec-dev.org/${{ github.base_ref }}' - - name: Sync packages with the remote repository - if: ${{ contains(github.event.pull_request.labels.*.name, 'experimental') }} - uses: ./.github/actions/sync-repository - with: - local-path: build/repo/ - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} - ssh-port: ${{ secrets.SSH_PORT }} - remote-path: ${{ secrets.REMOTE_SSH }}:/srv/toltec/experimental + lint: + name: Check that it conforms to the style guide + runs-on: ubuntu-24.04 + steps: + - name: Checkout the Git repository + uses: actions/checkout@v4 + - name: Setup Toltec dependencies + uses: ./.github/actions/setup + - name: Check formatting + run: make format + - name: Check for erroneous constructs + run: make lint + pr: + name: Check that it builds without error + runs-on: ubuntu-24.04 + needs: lint + steps: + - name: Checkout the Git repository + uses: actions/checkout@v4 + - name: Setup Toltec dependencies + uses: ./.github/actions/setup + - name: Build packages + run: FLAGS='--remote-repo https://toltec-dev.org/${{ github.base_ref }}' make repo-new + - name: Save the build output + uses: actions/upload-artifact@v4 + with: + name: repo + path: build/repo + - name: Build packages for experimental + if: ${{ contains(github.event.pull_request.labels.*.name, 'experimental') }} + run: make repo FLAGS='--remote-repo https://toltec-dev.org/${{ github.base_ref }}' + - name: Sync packages with the remote repository + if: ${{ contains(github.event.pull_request.labels.*.name, 'experimental') }} + uses: ./.github/actions/sync-repository + with: + local-path: build/repo/ + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} + ssh-port: ${{ secrets.SSH_PORT }} + remote-path: ${{ secrets.REMOTE_SSH }}:/srv/toltec/experimental diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml index 2ad14c7bf..cae93c130 100644 --- a/.github/workflows/stable.yml +++ b/.github/workflows/stable.yml @@ -1,48 +1,48 @@ name: stable on: - push: - branches: - - stable + push: + branches: + - stable jobs: - stable: - name: Build and publish the stable channel - runs-on: ubuntu-22.04 - steps: - - name: Checkout the Git repository - uses: actions/checkout@v4 - - name: Setup Toltec dependencies - uses: ./.github/actions/setup - - name: Build packages - run: | - make repo FLAGS='--remote-repo ${{ secrets.REMOTE_HTTP }}/stable' - - name: Sync packages with the remote repository - uses: ./.github/actions/sync-repository - with: - local-path: build/repo/ - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} - ssh-port: ${{ secrets.SSH_PORT }} - remote-path: ${{ secrets.REMOTE_SSH }}:/srv/toltec/stable - - name: Trigger website rebuild - run: gh api repos/toltec-dev/web/dispatches -f event_type='update-bootstrap-from-stable' - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} - - name: Create Github Release - continue-on-error: true - run: | - sudo apt-get update && sudo apt-get install -y hub - hub release create -t $SHA -m $MESSAGE $(date +%G-W%V-%u) - env: - SHA: ${{ github.sha }} - GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} - MESSAGE: ${{ github.event.commits[0].message }} - - name: Send notification to Discord - continue-on-error: true - uses: ./.github/actions/discord-send - with: - channel: ${{ secrets.DISCORD_STABLE_CHANNEL_ID }} - token: ${{ secrets.DISCORD_STABLE_CHANNEL_TOKEN }} - title: New Toltec stable update available - link: https://toltec-dev.org/stable - color: 0x2ea043 - message: ${{ github.event.commits[0].message }} + stable: + name: Build and publish the stable channel + runs-on: ubuntu-24.04 + steps: + - name: Checkout the Git repository + uses: actions/checkout@v4 + - name: Setup Toltec dependencies + uses: ./.github/actions/setup + - name: Build packages + run: | + make repo FLAGS='--remote-repo ${{ secrets.REMOTE_HTTP }}/stable' + - name: Sync packages with the remote repository + uses: ./.github/actions/sync-repository + with: + local-path: build/repo/ + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} + ssh-port: ${{ secrets.SSH_PORT }} + remote-path: ${{ secrets.REMOTE_SSH }}:/srv/toltec/stable + - name: Trigger website rebuild + run: gh api repos/toltec-dev/web/dispatches -f event_type='update-bootstrap-from-stable' + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + - name: Create Github Release + continue-on-error: true + run: | + sudo apt-get update && sudo apt-get install -y hub + hub release create -t $SHA -m $MESSAGE $(date +%G-W%V-%u) + env: + SHA: ${{ github.sha }} + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + MESSAGE: ${{ github.event.commits[0].message }} + - name: Send notification to Discord + continue-on-error: true + uses: ./.github/actions/discord-send + with: + channel: ${{ secrets.DISCORD_STABLE_CHANNEL_ID }} + token: ${{ secrets.DISCORD_STABLE_CHANNEL_TOKEN }} + title: New Toltec stable update available + link: https://toltec-dev.org/stable + color: 0x2ea043 + message: ${{ github.event.commits[0].message }} diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 24446c870..57d0d9a8d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,35 +1,35 @@ name: testing on: - push: - branches: - - testing + push: + branches: + - testing jobs: - testing: - name: Build and publish the testing channel - runs-on: ubuntu-22.04 - steps: - - name: Checkout the Git repository - uses: actions/checkout@v4 - - name: Setup Toltec dependencies - uses: ./.github/actions/setup - - name: Build packages - run: | - make repo FLAGS='--remote-repo ${{ secrets.REMOTE_HTTP }}/testing' - - name: Sync packages with the remote repository - uses: ./.github/actions/sync-repository - with: - local-path: build/repo/ - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} - ssh-port: ${{ secrets.SSH_PORT }} - remote-path: ${{ secrets.REMOTE_SSH }}:/srv/toltec/testing - - name: Send notification to Discord - continue-on-error: true - uses: ./.github/actions/discord-send - with: - channel: ${{ secrets.DISCORD_TESTING_CHANNEL_ID }} - token: ${{ secrets.DISCORD_TESTING_CHANNEL_TOKEN }} - title: New Toltec testing update available - link: https://toltec-dev.org/testing - color: 0xe3b341 - message: ${{ github.event.commits[0].message }} + testing: + name: Build and publish the testing channel + runs-on: ubuntu-24.04 + steps: + - name: Checkout the Git repository + uses: actions/checkout@v4 + - name: Setup Toltec dependencies + uses: ./.github/actions/setup + - name: Build packages + run: | + make repo FLAGS='--remote-repo ${{ secrets.REMOTE_HTTP }}/testing' + - name: Sync packages with the remote repository + uses: ./.github/actions/sync-repository + with: + local-path: build/repo/ + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} + ssh-port: ${{ secrets.SSH_PORT }} + remote-path: ${{ secrets.REMOTE_SSH }}:/srv/toltec/testing + - name: Send notification to Discord + continue-on-error: true + uses: ./.github/actions/discord-send + with: + channel: ${{ secrets.DISCORD_TESTING_CHANNEL_ID }} + token: ${{ secrets.DISCORD_TESTING_CHANNEL_TOKEN }} + title: New Toltec testing update available + link: https://toltec-dev.org/testing + color: 0xe3b341 + message: ${{ github.event.commits[0].message }}