Run automated code formatters #273
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run automated code formatters | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '13 00 * * *' # utc | |
pull_request: | |
branches: | |
- develop | |
paths: | |
- '.github/workflows/code-formatting.yml' | |
jobs: | |
code-formatters: | |
runs-on: [self-hosted, vm] | |
timeout-minutes: 60 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
# NOTE(mikal): git repos are checked out to /srv/github/_work/{org}/{repo} | |
# which is available as GITHUB_WORKSPACE. You can find other environment | |
# variables at https://docs.github.com/en/actions/learn-github-actions/environment-variables | |
steps: | |
- name: Set environment variables | |
run: | | |
echo "SHAKENFIST_NAMESPACE=$(hostname)" >> $GITHUB_ENV | |
- name: Checkout shakenfist | |
uses: actions/checkout@v4 | |
with: | |
path: shakenfist | |
fetch-depth: 0 | |
- name: Checkout the actions repository | |
uses: actions/checkout@v4 | |
with: | |
repository: shakenfist/actions | |
path: actions | |
fetch-depth: 0 | |
- name: Install the github command line | |
run: | | |
sudo apt update | |
sudo apt install -y curl | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
sudo apt update | |
sudo apt install -y gh | |
- name: Install formatting tools in a venv | |
run: | | |
sudo DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=-1 -o Dpkg::Options::="--force-confold" -y \ | |
install git python3-cffi python3-dev python3-grpcio python3-pip python3-venv python3-wheel | |
python3 -m venv --system-site-packages ${RUNNER_TEMP}/venv | |
cd ${GITHUB_WORKSPACE}/shakenfist | |
${RUNNER_TEMP}/venv/bin/pip install -r requirements.txt | |
${RUNNER_TEMP}/venv/bin/pip install pyupgrade reorder-python-imports | |
- name: Scan for obsolete syntax | |
env: | |
GITHUB_TOKEN: ${{ secrets.DEPENDENCIES_TOKEN }} | |
run: | | |
cd ${GITHUB_WORKSPACE}/shakenfist | |
. ${RUNNER_TEMP}/venv/bin/activate | |
${GITHUB_WORKSPACE}/actions/tools/ci_code_formatting.sh 39 |