Skip to content

Commit 3e6100b

Browse files
committed
Create V3 of VoronDesign github workflows
1 parent 4fd82be commit 3e6100b

8 files changed

Lines changed: 130 additions & 178 deletions

.github/workflows/check-stl-corruption.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,6 @@ jobs:
6868
id: check-stls
6969
run: |-
7070
python3 ${{ github.workspace }}/scripts/check_stl_corruption.py -vfg --input_dir=${{ github.workspace }}/${{ inputs.cache-directory }} --output_dir=${{runner.temp}}/fixed/
71-
- if: ${{ failure() }}
72-
name: Add STL Issues label
73-
uses: actions/github-script@v6
74-
with:
75-
script: |
76-
github.rest.issues.addLabels({
77-
issue_number: context.payload.pull_request.number,
78-
owner: context.repo.owner,
79-
repo: context.repo.repo,
80-
labels: ['STL Issues']
81-
})
82-
- if: success() && contains(github.event.pull_request.labels.*.name, 'STL Issues')
83-
name: Remove STL Issues label
84-
uses: actions/github-script@v6
85-
with:
86-
script: |
87-
github.rest.issues.removeLabel({
88-
issue_number: context.payload.pull_request.number,
89-
owner: context.repo.owner,
90-
repo: context.repo.repo,
91-
name: ['STL Issues']
92-
})
9371
- if: ${{ always() }}
9472
# Upload fixed STLs as artifact
9573
name: Upload fixed STLs ⬆️

.github/workflows/check-stl-rotation.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,6 @@ jobs:
8787
IMAGEKIT_SUBFOLDER: ci_${{github.event.number}}
8888
run: |-
8989
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}}
90-
- if: ${{ failure() }}
91-
name: Add STL Rotation Warnings label
92-
uses: actions/github-script@v6
93-
with:
94-
script: |
95-
github.rest.issues.addLabels({
96-
issue_number: context.payload.pull_request.number,
97-
owner: context.repo.owner,
98-
repo: context.repo.repo,
99-
labels: ['STL Rotation Warnings']
100-
})
101-
- if: success() && contains(github.event.pull_request.labels.*.name, 'STL Rotation Warnings')
102-
name: Remove STL Rotation Warnings label
103-
uses: actions/github-script@v6
104-
with:
105-
script: |
106-
github.rest.issues.removeLabel({
107-
issue_number: context.payload.pull_request.number,
108-
owner: context.repo.owner,
109-
repo: context.repo.repo,
110-
name: ['STL Rotation Warnings']
111-
})
11290
- if: ${{ always() }}
11391
# Upload rotated STLs as artifact
11492
name: Upload rotated STLs ⬆️

.github/workflows/generate-pr-comment.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: Post PR comment and assign labels
3+
on:
4+
workflow_call:
5+
jobs:
6+
run:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout workflows repo ↪️
10+
# Check out .github repo to gain access to scripts
11+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
12+
with:
13+
repository: VoronDesign/.github
14+
persist-credentials: false
15+
- name: Setup python 3.11 🐍
16+
id: python311
17+
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0
18+
with:
19+
python-version: '3.11'
20+
- name: Install python packages 🛠️
21+
# Install required packages
22+
id: pip-install-packages
23+
run: |
24+
pip install requests
25+
- name: Download artifact
26+
# Download the artifact that was stored during the PR CI process
27+
# This file contains the action_run_id and the pull_request number
28+
# which are often not accessible from contexts
29+
uses: actions/github-script@v6
30+
with:
31+
script: |
32+
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
run_id: ${{github.event.workflow_run.id }},
36+
});
37+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
38+
return artifact.name == "pr"
39+
})[0];
40+
var download = await github.rest.actions.downloadArtifact({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
artifact_id: matchArtifact.id,
44+
archive_format: 'zip',
45+
});
46+
var fs = require('fs');
47+
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
48+
- run: unzip pr.zip
49+
- name: Get action_run_id and pr_number
50+
# The PR file contains two files, one with the PR number and one with the action run ID
51+
# Store them in outputs so they're easily accessible to other steps in this workflow
52+
id: get_artifact_values
53+
uses: actions/github-script@v6
54+
with:
55+
github-token: ${{ secrets.GITHUB_TOKEN }}
56+
script: |
57+
var fs = require('fs');
58+
var pr_number = String(fs.readFileSync('${{github.workspace}}/pr_number'));
59+
var action_run_id = String(fs.readFileSync('${{github.workspace}}/action_run_id'));
60+
core.setOutput('pr_number', pr_number);
61+
core.setOutput('action_run_id', action_run_id);
62+
- name: Generate PR Comment 📃
63+
id: generate_pr_comment
64+
# Generate the contents of the PR comment, this also stores the labels to be set on the PR
65+
# in the output variable "LABELS_TO_SET"
66+
run: |
67+
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
68+
- name: Post/Update PR Comment 📣
69+
# Actually post/update the comment in the PR
70+
uses: thollander/actions-comment-pull-request@8c77f42bbcc27c832a3a5962c8f9a60e34b594f3
71+
with:
72+
filePath: ${{ github.workspace }}/pr/pr-comment.md
73+
pr_number: ${{ steps.get_artifact_values.outputs.pr_number }}
74+
comment_tag: voron_users_ci
75+
- name: Set labels on PR
76+
# The python script determined which labels should be set. By using PUT, this workflow will
77+
# also remove all labels that are not explicitly set by the python script.
78+
env:
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |-
81+
curl --request PUT \
82+
--header "Accept: application/vnd.github+json" \
83+
--header "Authorization: Bearer $GH_TOKEN" \
84+
--header "X-GitHub-Api-Version: 2022-11-28" \
85+
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.get_artifact_values.outputs.pr_number }}/labels \
86+
-d '{"labels":[${{ steps.generate_pr_comment.outputs.LABELS_TO_SET}}]}'

.github/workflows/pr_checkout_check_whitespace_cache.yml

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,22 @@ jobs:
4040
name: Check whitespace in files/folders 🔍
4141
shell: bash
4242
run: |
43+
echo "### The following changes were detected:" >> $GITHUB_STEP_SUMMARY
4344
ret_val=0
45+
export TMP_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
4446
IFS=$'\n'
45-
read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-files.outputs.all_changed_files }}"
46-
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
47+
for file in $TMP_FILES; do
4748
if [[ $file = *[[:space:]]* ]]; then
4849
echo "The following file contains whitespace: $file"
50+
echo "NOT_OK: \`$file\` contains whitespace!" >> $GITHUB_STEP_SUMMARY
4951
ret_val=1
52+
else
53+
echo "The following file is ok: $file"
54+
echo "OK: \`$file\`" >> $GITHUB_STEP_SUMMARY
5055
fi
5156
done
5257
unset IFS
5358
exit $ret_val
54-
- id: list-changed-files
55-
# List all changed files for debugging
56-
name: List all changed files 📃
57-
run: |
58-
echo "### The following changes were detected:" >> $GITHUB_STEP_SUMMARY
59-
echo "```" >> $GITHUB_STEP_SUMMARY
60-
echo "${{ steps.changed-files.outputs.all_changed_files }}" >> $GITHUB_STEP_SUMMARY
61-
echo "```" >> $GITHUB_STEP_SUMMARY
6259
- name: Perform Sparse Checkout ↪️
6360
# Perform a sparse checkout, checking out only the files of the PR
6461
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
@@ -71,37 +68,15 @@ jobs:
7168
run: |
7269
cd ${{ github.workspace }}/${{ inputs.cache-directory }}
7370
tree -a -I '.git'
74-
- if: ${{ failure() }}
75-
name: Add Whitespace Issues label
76-
uses: actions/github-script@v6
77-
with:
78-
script: |
79-
github.rest.issues.addLabels({
80-
issue_number: context.payload.pull_request.number,
81-
owner: context.repo.owner,
82-
repo: context.repo.repo,
83-
labels: ['Whitespace Issues']
84-
})
85-
- if: success() && contains(github.event.pull_request.labels.*.name, 'Whitespace Issues')
86-
name: Remove File & Folder Whitespace Issues label
87-
uses: actions/github-script@v6
88-
with:
89-
script: |
90-
github.rest.issues.removeLabel({
91-
issue_number: context.payload.pull_request.number,
92-
owner: context.repo.owner,
93-
repo: context.repo.repo,
94-
name: ['Whitespace Issues']
95-
})
9671
- name: Determine changed file types 🔍
9772
# Check which files were changed to enable skipping of expensive CI steps later
9873
uses: dorny/paths-filter@4067d885736b84de7c414f582ac45897079b0a78
9974
id: filter
10075
with:
10176
filters: |
10277
stl:
103-
- '**/.stl'
104-
- '**/.STL'
78+
- '**/*.stl'
79+
- '**/*.STL'
10580
yaml:
10681
- '**/.metadata.yml'
10782
- if: ${{ inputs.cache-key != '' }}

.github/workflows/validate-metadata-files.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,3 @@ jobs:
3939
yamlFiles: '**/.metadata.yml'
4040
yamlWorkingDirectory: ${{github.workspace}}/${{ inputs.cache-directory }}
4141
enableGithubStepSummary: true
42-
- if: ${{ failure() }}
43-
name: Add Metadata Issues label
44-
uses: actions/github-script@v6
45-
with:
46-
script: |
47-
github.rest.issues.addLabels({
48-
issue_number: context.payload.pull_request.number,
49-
owner: context.repo.owner,
50-
repo: context.repo.repo,
51-
labels: ['Metadata Issues']
52-
})
53-
- if: success() && contains(github.event.pull_request.labels.*.name, 'Metadata Issues')
54-
name: Remove Metadata Issues label
55-
uses: actions/github-script@v6
56-
with:
57-
script: |
58-
github.rest.issues.removeLabel({
59-
issue_number: context.payload.pull_request.number,
60-
owner: context.repo.owner,
61-
repo: context.repo.repo,
62-
name: ['Metadata Issues']
63-
})

0 commit comments

Comments
 (0)