-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create v1 of VoronDesign reusable workflows
- Loading branch information
Showing
13 changed files
with
1,070 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
name: Check STLs in folder for corruption | ||
on: | ||
workflow_call: | ||
inputs: | ||
cache-key: | ||
description: Cache key where STL files to check are cached | ||
type: string | ||
required: true | ||
cache-directory: | ||
description: Cache subdirectory matching the cache key | ||
type: string | ||
required: true | ||
python-cache-key: | ||
description: Cache key for previously set up python environment | ||
type: string | ||
required: false | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout workflows repo ↪️ | ||
# Check out .github repo to gain access to scripts | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | ||
with: | ||
repository: VoronDesign/.github | ||
- name: Get repository files cache 🧰 | ||
# Get cached PR files | ||
uses: actions/cache/restore@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 | ||
id: get-repo-cache | ||
with: | ||
path: ${{ github.workspace }}/${{ inputs.cache-directory }} | ||
key: ${{ inputs.cache-key }} | ||
- name: Setup python 3.11 🐍 | ||
id: python311 | ||
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 | ||
with: | ||
python-version: '3.11' | ||
- name: Get python package cache 🧰 | ||
# Get cached python dependencies (to avoid repetitive pip install's) | ||
uses: actions/cache/restore@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 | ||
id: cache-python | ||
env: | ||
cache-name: cache-python | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ inputs.python-cache-key }} | ||
- name: Install apt packages (cached) 🛠️🧰 | ||
# Get cached apt dependencies (or install them on cache-miss) | ||
uses: awalsh128/cache-apt-pkgs-action@1850ee53f6e706525805321a3f2f863dcf73c962 | ||
with: | ||
packages: admesh, libadmesh-dev | ||
version: 1.0 | ||
- if: ${{ inputs.python-cache-key == '' || steps.cache-python.outputs.cache-hit != 'true' }} | ||
# If no cache-key was provided, or cache-miss occurred on python cache, install required packages | ||
# Note: This has to run AFTER the apt package install, as libadmesh is required for the pip package | ||
name: Install python packages 🛠️ | ||
id: pip-install-packages | ||
run: | | ||
pip install admesh | ||
- name: Show tool versions 🏃 | ||
# Print tool versions for debugging purposes | ||
id: run-tools | ||
run: | | ||
admesh --version | ||
- name: Check for STL corruption ✅ | ||
# Run the STL corruption checker | ||
id: check-stls | ||
run: |- | ||
python3 ${{ github.workspace }}/scripts/check_stl_corruption.py -vfg --input_dir=${{ github.workspace }}/${{ inputs.cache-directory }} --output_dir=${{runner.temp}}/fixed/ | ||
- if: ${{ always() }} | ||
# Upload fixed STLs as artifact | ||
name: Upload fixed STLs ⬆️ | ||
uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05 | ||
with: | ||
name: pr_${{github.event.number}}.${{github.run_number}}_fixed_stls | ||
path: ${{runner.temp}}/fixed/ | ||
if-no-files-found: ignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
name: Check STLs in folder for possibly suboptimal rotation | ||
on: | ||
workflow_call: | ||
inputs: | ||
cache-key: | ||
description: Cache key where STL files to check are cached | ||
type: string | ||
required: true | ||
cache-directory: | ||
description: Cache directory matching the cache key | ||
type: string | ||
required: true | ||
python-cache-key: | ||
description: Cache key for previously set up python environment | ||
type: string | ||
required: false | ||
imagekit-url-endpoint: | ||
required: true | ||
type: string | ||
description: IMAGEKIT.io endpoint to push images to | ||
secrets: | ||
IMAGEKIT_PRIVATE_KEY: | ||
required: true | ||
IMAGEKIT_PUBLIC_KEY: | ||
required: true | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout workflows repo ↪️ | ||
# Check out .github repo to gain access to scripts | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | ||
with: | ||
repository: VoronDesign/.github | ||
- name: Get repository files cache 🧰 | ||
# Get cached PR files | ||
uses: actions/cache/restore@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 | ||
id: get-repo-cache | ||
with: | ||
path: ${{ github.workspace }}/${{ inputs.cache-directory }} | ||
key: ${{ inputs.cache-key }} | ||
- name: Setup python 3.11 🐍 | ||
id: python311 | ||
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 | ||
with: | ||
python-version: '3.11' | ||
- name: Get python package cache 🧰 | ||
# Get cached python dependencies (to avoid repetitive pip install's) | ||
uses: actions/cache/restore@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 | ||
id: cache-python | ||
env: | ||
cache-name: cache-python | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ inputs.python-cache-key }} | ||
- if: ${{ inputs.python-cache-key == '' || steps.cache-python.outputs.cache-hit != 'true' }} | ||
# If no cache-key was provided, or cache-miss occurred on python cache, install required packages | ||
name: Install python packages 🛠️ | ||
id: pip-install-packages | ||
run: | | ||
pip install git+https://github.com/ChristophSchranz/Tweaker-3.git imagekitio | ||
- id: download-stl-thumb | ||
# Download STL thumb binary | ||
name: Download STL thumb ⬇️ | ||
run: | | ||
curl -L https://github.com/unlimitedbacon/stl-thumb/releases/download/v0.5.0/stl-thumb_0.5.0_amd64.deb --output ${{ runner.temp }}/stl-thumb_0.5.0_amd64.deb | ||
- name: Install apt packages (cached) 🛠️🧰 | ||
# Get cached apt dependencies (or install them on cache-miss) | ||
uses: awalsh128/cache-apt-pkgs-action@1850ee53f6e706525805321a3f2f863dcf73c962 | ||
with: | ||
packages: ${{ runner.temp }}/stl-thumb_0.5.0_amd64.deb | ||
version: 1.0 | ||
- name: Show tool versions 🏃 | ||
# Print tool versions for debugging purposes | ||
id: run-tools | ||
run: | | ||
tweaker3 --version | ||
stl-thumb --version | ||
- name: Check STLs for rotation issues ✅ | ||
# Run the STL rotation checker | ||
id: check-stl-rotation | ||
env: | ||
IMAGEKIT_PRIVATE_KEY: ${{ secrets.IMAGEKIT_PRIVATE_KEY }} | ||
IMAGEKIT_PUBLIC_KEY: ${{ secrets.IMAGEKIT_PUBLIC_KEY }} | ||
IMAGEKIT_URL_ENDPOINT: ${{ inputs.imagekit-url-endpoint }} | ||
IMAGEKIT_SUBFOLDER: ci_${{github.event.number}} | ||
run: |- | ||
python3 ${{ github.workspace }}/scripts/check_stl_rotation.py -vg --input_dir=${{ github.workspace }}/${{ inputs.cache-directory }} --output_dir=${{runner.temp}}/rotated/ --temp_image_dir=${{runner.temp}} | ||
- if: ${{ always() }} | ||
# Upload rotated STLs as artifact | ||
name: Upload rotated STLs ⬆️ | ||
uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05 | ||
with: | ||
name: pr_${{github.event.number}}.${{github.run_number}}_rotated_stls | ||
path: ${{runner.temp}}/rotated/ | ||
if-no-files-found: ignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
name: Generate readme and commit | ||
on: | ||
workflow_call: | ||
inputs: | ||
subdirectory: | ||
description: Name of the directory in which the printer mods are located and | ||
where README.md is generated | ||
type: string | ||
required: true | ||
commit_msg: | ||
description: Commit message to use (don't forget to add [skip ci]) | ||
type: string | ||
required: false | ||
default: Generate VoronUsers printer_mods README.md [skip ci] | ||
commit_user: | ||
description: Commit username to use | ||
type: string | ||
required: false | ||
default: Readme-Committer | ||
commit_email: | ||
description: Commit eMail to use | ||
type: string | ||
required: false | ||
default: [email protected] | ||
secrets: | ||
VORON_BOT_GITHUB_PAT: | ||
description: GitHub token or PAT token | ||
required: false | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout workflows repo ↪️ | ||
# Check out .github repo to gain access to scripts | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | ||
with: | ||
repository: VoronDesign/.github | ||
persist-credentials: false | ||
- name: Perform Sparse Checkout ↪️ | ||
# Perform a sparse checkout, checking out only yaml files and the current README.md | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | ||
with: | ||
path: ${{ github.workspace }}/sparse-repo | ||
sparse-checkout: | | ||
${{ inputs.subdirectory }}/**/.metadata.yml | ||
${{ inputs.subdirectory }}/README.md | ||
token: ${{ secrets.VORON_BOT_GITHUB_PAT }} | ||
sparse-checkout-cone-mode: false | ||
- name: Setup python 3.11 🐍 | ||
id: python311 | ||
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 | ||
with: | ||
python-version: '3.11' | ||
- name: Install python packages 🛠️ | ||
id: pip-install-packages | ||
run: | | ||
pip install pyyaml | ||
- name: Generate README.md 📃 | ||
# Generate the new readme file | ||
run: | | ||
cd ${{ github.workspace }}/sparse-repo/${{ inputs.subdirectory }} | ||
export PREVIEW=false | ||
python3 ${{ github.workspace }}/scripts/generate_readme.py | ||
- name: Commit files 💾 | ||
# Commit the new readme using the GH bot credentials | ||
run: | | ||
cd ${{ github.workspace }}/sparse-repo/ | ||
git config user.email ${{ inputs.commit_email }} | ||
git config user.name ${{ inputs.commit_user }} | ||
git add ${{ inputs.subdirectory }}/README.md | ||
git commit -m "${{ inputs.commit_msg }}" || true | ||
- name: Push changes ⬆️ | ||
# Push the changes | ||
uses: ad-m/github-push-action@d9117be7cad08757e9e906a1bcd1716d6b192db5 | ||
with: | ||
github_token: ${{ secrets.VORON_BOT_GITHUB_PAT }} | ||
directory: ${{ github.workspace }}/sparse-repo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
name: Get PR contents, check whitespace and cache | ||
on: | ||
workflow_call: | ||
inputs: | ||
branch: | ||
description: Branch to check out sparsely, e.g. refs/pull/1/merge | ||
type: string | ||
required: true | ||
default: ${{ github.ref }} | ||
cache-key: | ||
description: Name of the cache key for the checked out files | ||
type: string | ||
required: true | ||
cache-directory: | ||
description: Cache subdirectory matching the cache key | ||
type: string | ||
required: true | ||
outputs: | ||
stl: | ||
description: Were STLs changed on this PR | ||
value: ${{ jobs.run.outputs.stl }} | ||
yaml: | ||
description: Were YAML files changed on this PR | ||
value: ${{ jobs.run.outputs.yaml }} | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
outputs: | ||
stl: ${{ steps.filter.outputs.stl }} | ||
yaml: ${{ steps.filter.outputs.yaml }} | ||
steps: | ||
- id: changed-files | ||
# Check out files, separate with newlines to catch whitespace in filenames | ||
uses: tj-actions/changed-files@v37 | ||
with: | ||
separator: "\n" | ||
- id: check-whitespace | ||
# Check whitespace in files obtained by the changed-files step | ||
name: Check whitespace in files/folders 🔍 | ||
shell: bash | ||
run: | | ||
ret_val=0 | ||
IFS=$'\n' | ||
read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-files.outputs.all_changed_files }}" | ||
for file in "${MODIFIED_FILES_ARRAY[@]}"; do | ||
if [[ $file = *[[:space:]]* ]]; then | ||
echo "The following file contains whitespace: $file" | ||
ret_val=1 | ||
fi | ||
done | ||
unset IFS | ||
exit $ret_val | ||
- id: list-changed-files | ||
# List all changed files for debugging | ||
name: List all changed files 📃 | ||
run: | | ||
echo "### The following changes were detected:" >> $GITHUB_STEP_SUMMARY | ||
echo "${{ steps.changed-files.outputs.all_changed_files }}" >> $GITHUB_STEP_SUMMARY | ||
- name: Perform Sparse Checkout ↪️ | ||
# Perform a sparse checkout, checking out only the files of the PR | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
path: ${{ github.workspace }}/${{ inputs.cache-directory }} | ||
sparse-checkout: ${{ steps.changed-files.outputs.all_changed_files }} | ||
sparse-checkout-cone-mode: false | ||
- name: List checked out files 📃 | ||
run: | | ||
cd ${{ github.workspace }}/${{ inputs.cache-directory }} | ||
tree -a -I '.git' | ||
- name: Determine changed file types 🔍 | ||
# Check which files were changed to enable skipping of expensive CI steps later | ||
uses: dorny/paths-filter@4067d885736b84de7c414f582ac45897079b0a78 | ||
id: filter | ||
with: | ||
filters: | | ||
stl: | ||
- '**/.stl' | ||
- '**/.STL' | ||
yaml: | ||
- '**/.metadata.yml' | ||
- if: ${{ inputs.cache-key != '' }} | ||
# If a cache key was provided, cache the obtained directory under this key | ||
name: Cache checked out files 🧰 | ||
id: build-repo-cache | ||
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 | ||
with: | ||
path: ${{ github.workspace }}/${{ inputs.cache-directory }} | ||
key: ${{ inputs.cache-key }} |
Oops, something went wrong.