Skip to content

Commit

Permalink
Create V3 of VoronDesign github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
FHeilmann committed Jul 17, 2023
1 parent 4fd82be commit 3e6100b
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 178 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/check-stl-corruption.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,6 @@ jobs:
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: ${{ failure() }}
name: Add STL Issues label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['STL Issues']
})
- if: success() && contains(github.event.pull_request.labels.*.name, 'STL Issues')
name: Remove STL Issues label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['STL Issues']
})
- if: ${{ always() }}
# Upload fixed STLs as artifact
name: Upload fixed STLs ⬆️
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/check-stl-rotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,6 @@ jobs:
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: ${{ failure() }}
name: Add STL Rotation Warnings label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['STL Rotation Warnings']
})
- if: success() && contains(github.event.pull_request.labels.*.name, 'STL Rotation Warnings')
name: Remove STL Rotation Warnings label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['STL Rotation Warnings']
})
- if: ${{ always() }}
# Upload rotated STLs as artifact
name: Upload rotated STLs ⬆️
Expand Down
67 changes: 0 additions & 67 deletions .github/workflows/generate-pr-comment.yml

This file was deleted.

86 changes: 86 additions & 0 deletions .github/workflows/pr-comment-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: Post PR comment and assign labels
on:
workflow_call:
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: Setup python 3.11 🐍
id: python311
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0
with:
python-version: '3.11'
- name: Install python packages 🛠️
# Install required packages
id: pip-install-packages
run: |
pip install requests
- name: Download artifact
# Download the artifact that was stored during the PR CI process
# This file contains the action_run_id and the pull_request number
# which are often not accessible from contexts
uses: actions/github-script@v6
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Get action_run_id and pr_number
# The PR file contains two files, one with the PR number and one with the action run ID
# Store them in outputs so they're easily accessible to other steps in this workflow
id: get_artifact_values
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var pr_number = String(fs.readFileSync('${{github.workspace}}/pr_number'));
var action_run_id = String(fs.readFileSync('${{github.workspace}}/action_run_id'));
core.setOutput('pr_number', pr_number);
core.setOutput('action_run_id', action_run_id);
- name: Generate PR Comment 📃
id: generate_pr_comment
# Generate the contents of the PR comment, this also stores the labels to be set on the PR
# in the output variable "LABELS_TO_SET"
run: |
python3 ${{ github.workspace }}/scripts/generate_pr_comment.py --repository=${{ github.repository }} --action_id=${{ steps.get_artifact_values.outputs.action_run_id }} --out_file=${{ github.workspace }}/pr/pr-comment.md
- name: Post/Update PR Comment 📣
# Actually post/update the comment in the PR
uses: thollander/actions-comment-pull-request@8c77f42bbcc27c832a3a5962c8f9a60e34b594f3
with:
filePath: ${{ github.workspace }}/pr/pr-comment.md
pr_number: ${{ steps.get_artifact_values.outputs.pr_number }}
comment_tag: voron_users_ci
- name: Set labels on PR
# The python script determined which labels should be set. By using PUT, this workflow will
# also remove all labels that are not explicitly set by the python script.
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
curl --request PUT \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer $GH_TOKEN" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.get_artifact_values.outputs.pr_number }}/labels \
-d '{"labels":[${{ steps.generate_pr_comment.outputs.LABELS_TO_SET}}]}'
43 changes: 9 additions & 34 deletions .github/workflows/pr_checkout_check_whitespace_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,22 @@ jobs:
name: Check whitespace in files/folders 🔍
shell: bash
run: |
echo "### The following changes were detected:" >> $GITHUB_STEP_SUMMARY
ret_val=0
export TMP_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
IFS=$'\n'
read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-files.outputs.all_changed_files }}"
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
for file in $TMP_FILES; do
if [[ $file = *[[:space:]]* ]]; then
echo "The following file contains whitespace: $file"
echo "NOT_OK: \`$file\` contains whitespace!" >> $GITHUB_STEP_SUMMARY
ret_val=1
else
echo "The following file is ok: $file"
echo "OK: \`$file\`" >> $GITHUB_STEP_SUMMARY
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 "```" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.changed-files.outputs.all_changed_files }}" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
- name: Perform Sparse Checkout ↪️
# Perform a sparse checkout, checking out only the files of the PR
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
Expand All @@ -71,37 +68,15 @@ jobs:
run: |
cd ${{ github.workspace }}/${{ inputs.cache-directory }}
tree -a -I '.git'
- if: ${{ failure() }}
name: Add Whitespace Issues label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Whitespace Issues']
})
- if: success() && contains(github.event.pull_request.labels.*.name, 'Whitespace Issues')
name: Remove File & Folder Whitespace Issues label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['Whitespace Issues']
})
- 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'
- '**/*.stl'
- '**/*.STL'
yaml:
- '**/.metadata.yml'
- if: ${{ inputs.cache-key != '' }}
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/validate-metadata-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,3 @@ jobs:
yamlFiles: '**/.metadata.yml'
yamlWorkingDirectory: ${{github.workspace}}/${{ inputs.cache-directory }}
enableGithubStepSummary: true
- if: ${{ failure() }}
name: Add Metadata Issues label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Metadata Issues']
})
- if: success() && contains(github.event.pull_request.labels.*.name, 'Metadata Issues')
name: Remove Metadata Issues label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['Metadata Issues']
})
Loading

0 comments on commit 3e6100b

Please sign in to comment.