Skip to content

Commit

Permalink
Add pre-commit hooks for yml formatting and github actions linting.
Browse files Browse the repository at this point in the history
Reformat all yaml files and fix github actions improper attribute access.
Update errors caught by shellcheck.
  • Loading branch information
rtibbles committed Mar 8, 2025
1 parent d76b272 commit 896bc70
Show file tree
Hide file tree
Showing 10 changed files with 2,313 additions and 19,781 deletions.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

version: 2
updates:

# Maintain dependencies for Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
time: "00:00"

# Maintain dependencies for Github Actions
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/community-contribution-labeling.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Community Contribution Label

on:
issues:
types: [assigned, unassigned]

jobs:
call-label-action:
uses: learningequality/.github/.github/workflows/community-contribution-label.yml@main
secrets:
LE_BOT_APP_ID: ${{ secrets.LE_BOT_APP_ID }}
LE_BOT_PRIVATE_KEY: ${{ secrets.LE_BOT_PRIVATE_KEY }}
LE_BOT_APP_ID: ${{ secrets.LE_BOT_APP_ID }}
LE_BOT_PRIVATE_KEY: ${{ secrets.LE_BOT_PRIVATE_KEY }}
2 changes: 0 additions & 2 deletions .github/workflows/notify_team_new_comment.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Send a slack notification when a contributor comments on issue

on:
issue_comment:
types: [created]

jobs:
contributor_issue_comment:
uses: learningequality/.github/.github/workflows/notify_team_new_comment.yml@main
Expand Down
52 changes: 25 additions & 27 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
name: Linting

on:
push:
branches:
- develop
- main
- develop
- main
pull_request:
branches:
- develop
- main

- develop
- main
jobs:
pre_job:
name: Path match check
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths_ignore: '["**.po", "**.json"]'
linting:
name: All file linting
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
pre_job:
name: Path match check
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths_ignore: '["**.po", "**.json"]'
linting:
name: All file linting
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
30 changes: 13 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
# This workflow will upload a Python Package using pypa/gh-action-pypi-publish when a release is created

name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel pre-commit
- name: Build distribution
run: make dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel pre-commit
- name: Build distribution
run: make dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
174 changes: 95 additions & 79 deletions .github/workflows/pythontest.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: Python tests

on:
push:
branches:
- develop
- main
- develop
- main
pull_request:
branches:
- develop
- main

- develop
- main
jobs:
pre_job:
name: Path match check
Expand All @@ -34,77 +32,95 @@ jobs:
os: [windows-latest, ubuntu-latest, macos-13]
python-version: [3.9, '3.10', '3.11', '3.12']
include:
- os: ubuntu-latest
pippath: ~/.cache/pip
- os: macos-13
pippath: ~/Library/Caches/pip
- os: windows-latest
pippath: ~\AppData\Local\pip\Cache
- os: ubuntu-latest
pippath: ~/.cache/pip
- os: macos-13
pippath: ~/Library/Caches/pip
- os: windows-latest
pippath: ~\AppData\Local\pip\Cache
steps:
- uses: actions/checkout@v4
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
- name: Set up Python ${{ matrix.python-version }}
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Ubuntu dependencies
run: |
sudo apt-get -y -qq update
sudo apt-get install -y ffmpeg
sudo apt-get install -y poppler-utils
if: ${{ needs.pre_job.outputs.should_skip != 'true' && startsWith(matrix.os, 'ubuntu') }}
- name: Cache Mac dependencies
uses: actions/cache@v4
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'macos-13'
with:
path: ~/Library/Caches/Homebrew
key: ${{ runner.os }}-brew-${{ hashFiles('.github/workflows/pythontest.yml') }}
- name: Install Mac dependencies
run: |
# Due to this still unresolved issue: https://github.com/actions/runner-images/issues/9966
# We get a conflict between the Python 3.13 version installed in the runner,
# and the one installed by Homebrew. This is a workaround to fix it.
# This may break things when we add Python 3.13 to the matrix though.
brew unlink python@3.13 && brew link --overwrite python@3.13
brew install ffmpeg poppler
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'macos-13'
- name: Windows dependencies cache
id: windowscache
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'windows-latest'
uses: actions/cache@v4
with:
path: ${{ github.workspace }}\tools
key: ${{ runner.os }}-tools-${{ hashFiles('.github/workflows/pythontest.yml') }}
- name: Download and unpack Windows dependencies
if: needs.pre_job.outputs.should_skip != 'true' && steps.cache.windowscache.cache-hit != 'true' && matrix.os == 'windows-latest'
run: |
curl --output ffmpeg.zip -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
curl --output poppler.zip -L https://github.com/oschwartz10612/poppler-windows/releases/download/v21.11.0-0/Release-21.11.0-0.zip
7z x ffmpeg.zip -otools -y
7z x poppler.zip -otools -y
- name: Set paths to Windows dependencies
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'windows-latest'
run: |
echo "$pwd\tools\ffmpeg-master-latest-win64-gpl\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "$pwd\tools\poppler-21.11.0\Library\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache pip
if: ${{ needs.pre_job.outputs.should_skip != 'true' && !startsWith(runner.os, 'windows') }}
uses: actions/cache@v4
with:
path: ${{ matrix.pippath }}
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
- name: Install tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: |
python -m pip install --upgrade pip
pip install tox
- name: tox env cache
if: ${{ needs.pre_job.outputs.should_skip != 'true' && !startsWith(runner.os, 'windows') }}
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.tox/py${{ matrix.python-version }}
key: ${{ runner.os }}-tox-py${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
- name: Test with tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: tox -e py${{ matrix.python-version }}
- uses: actions/checkout@v4
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
- name: Set up Python ${{ matrix.python-version }}
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Ubuntu dependencies
run: |
sudo apt-get -y -qq update
sudo apt-get install -y ffmpeg
sudo apt-get install -y poppler-utils
if: ${{ needs.pre_job.outputs.should_skip != 'true' && startsWith(matrix.os, 'ubuntu') }}
- name: Cache Mac dependencies
uses: actions/cache@v4
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'macos-13'
with:
path: ~/Library/Caches/Homebrew
key: ${{ runner.os }}-brew-${{ hashFiles('.github/workflows/pythontest.yml') }}
- name: Install Mac dependencies
run: |
# Due to this still unresolved issue: https://github.com/actions/runner-images/issues/9966
# We get a conflict between the Python 3.13 version installed in the runner,
# and the one installed by Homebrew. This is a workaround to fix it.
# This may break things when we add Python 3.13 to the matrix though.
brew unlink python@3.13 && brew link --overwrite python@3.13
brew install ffmpeg poppler
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'macos-13'
- name: Windows dependencies cache
id: windowscache
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'windows-latest'
uses: actions/cache@v4
with:
path: ${{ github.workspace }}\tools
key: ${{ runner.os }}-${{ matrix.python-version }}-tools-${{ hashFiles('.github/workflows/pythontest.yml') }}
- name: Download Windows dependencies if needed
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'windows-latest'
shell: pwsh
run: |
# Create tools directory if it doesn't exist
New-Item -Path "tools" -ItemType Directory -Force -ErrorAction SilentlyContinue
# Check and download FFmpeg if needed
if (-not (Test-Path "$env:GITHUB_WORKSPACE\tools\ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe")) {
Write-Output "FFmpeg not found, downloading..."
curl.exe --output ffmpeg.zip -L https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
7z x ffmpeg.zip -otools -y
} else {
Write-Output "FFmpeg already exists, skipping download"
}
# Check and download Poppler if needed
if (-not (Test-Path "$env:GITHUB_WORKSPACE\tools\poppler-21.11.0\Library\bin\pdfinfo.exe")) {
Write-Output "Poppler not found, downloading..."
curl.exe --output poppler.zip -L https://github.com/oschwartz10612/poppler-windows/releases/download/v21.11.0-0/Release-21.11.0-0.zip
7z x poppler.zip -otools -y
} else {
Write-Output "Poppler already exists, skipping download"
}
- name: Set paths to Windows dependencies
if: needs.pre_job.outputs.should_skip != 'true' && matrix.os == 'windows-latest'
shell: pwsh
run: |
Add-Content -Path $env:GITHUB_PATH -Value "$env:GITHUB_WORKSPACE\tools\ffmpeg-master-latest-win64-gpl\bin" -Encoding utf8
Add-Content -Path $env:GITHUB_PATH -Value "$env:GITHUB_WORKSPACE\tools\poppler-21.11.0\Library\bin" -Encoding utf8
- name: Cache pip
if: ${{ needs.pre_job.outputs.should_skip != 'true' && !startsWith(runner.os, 'windows') }}
uses: actions/cache@v4
with:
path: ${{ matrix.pippath }}
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
- name: Install tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: |
python -m pip install --upgrade pip
pip install tox
- name: tox env cache
if: ${{ needs.pre_job.outputs.should_skip != 'true' && !startsWith(runner.os, 'windows') }}
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.tox/py${{ matrix.python-version }}
key: ${{ runner.os }}-tox-py${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
- name: Test with tox
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: tox -e py${{ matrix.python-version }}
3 changes: 1 addition & 2 deletions .github/workflows/update-pr-spreadsheet.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Update community pull requests spreadsheet
on:
pull_request_target:
types: [assigned,unassigned,opened,closed,reopened]

types: [assigned, unassigned, opened, closed, reopened]
jobs:
call-update-spreadsheet:
uses: learningequality/.github/.github/workflows/update-pr-spreadsheet.yml@main
Expand Down
Loading

0 comments on commit 896bc70

Please sign in to comment.