-
-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (118 loc) · 4.2 KB
/
pr-checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: PR Checks
on:
pull_request:
branches:
- main
- v*.*.x
permissions:
actions: write
pull-requests: write
jobs:
check_translations:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Run translation check script
run: python .scripts/missing_translation_check.py
- name: Check for Hard-coded strings
run: python .scripts/hardcode_string_check.py
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: leafo/gh-actions-lua@v10
- uses: leafo/gh-actions-luarocks@v4
- name: Install luarock dependencies
run: luarocks make --local rpglootfeed-1-1.rockspec
- name: Run Tests
run: make test-ci
- uses: actions/upload-artifact@v4
with:
name: luacov-html
path: luacov-html/
test_package:
runs-on: ubuntu-latest
env:
IS_FORK: ${{ github.event.pull_request.head.repo.fork }}
steps:
- name: Checkout code
if: env.IS_FORK == 'false'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Checkout code (fork)
if: env.IS_FORK == 'true'
uses: actions/checkout@v4
- name: Package
if: env.IS_FORK == 'false'
uses: BigWigsMods/packager@v2
with:
args: -d
pandoc: "false"
- name: Package (fork)
if: env.IS_FORK == 'true'
uses: BigWigsMods/packager@v2
with:
args: -d -n {package-name}-pr${{github.event.number}}-{nolib}{classic}
pandoc: "false"
- name: Capture Filenames
id: capture-filenames
run: |
FILE1=$(ls .release/RPGLootFeed-*-nolib.zip)
FILE2=$(ls .release/RPGLootFeed-*.zip | grep -v 'nolib')
echo "FILE1=$FILE1" >> $GITHUB_ENV
echo "FILE2=$FILE2" >> $GITHUB_ENV
- name: Upload RPGLootFeed ZIP
uses: actions/upload-artifact@v4
id: upload-zips-standard
with:
name: pr-pkg
path: ${{ env.FILE2 }}
- name: Upload RPGLootFeed Nolib ZIP
uses: actions/upload-artifact@v4
id: upload-zips-nolib
with:
name: pr-pkg-nolib
path: ${{ env.FILE1 }}
- name: Post PR comment
if: env.IS_FORK == 'false'
uses: actions/github-script@v7
with:
script: |
const commentIdentifier = "### Packaged ZIP files"; // Unique phrase to identify the comment
const linkStandard = `[RPGLootFeed ZIP (with libs)](${{ steps['upload-zips-standard'].outputs.artifact-url }})`;
const linkNolib = `[RPGLootFeed ZIP (nolib)](${{ steps['upload-zips-nolib'].outputs.artifact-url }})`;
const lastUpdated = new Date().toLocaleString('en-US', { timeZone: 'UTC', hour12: true });
const commentBody = `${linkStandard}\n${linkNolib}\n\nLast Updated: ${lastUpdated} (UTC)`;
const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const existingComment = comments.find(comment => comment.body.includes(commentIdentifier));
if (existingComment) {
// Update the existing comment
await github.rest.issues.updateComment({
comment_id: existingComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${commentIdentifier}\n${commentBody}`
});
} else {
// Create a new comment
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${commentIdentifier}\n${commentBody}`
});
}