New Crowdin updates #4525
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
name: Run Tests | |
on: | |
pull_request_target: | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: check urls | |
uses: urlstechie/urlchecker-action@master | |
with: | |
subfolder: docs | |
file_types: .en.md,.md | |
include_files: '\/([\w-]+)\.(en\.)?md' | |
exclude_patterns: 'avatars.githubusercontent.com,example.com,your-server-ip,your-server-hostname,nginx-server,apache-server,site1.com,site2.com,site.com,$releasever,proxy.rocky.lan,repo.rocky.lan,zfs-release,$host$request,fileserver.rockylinux.lan,your_fork_name,rundeck.rockylinux.org,manickathan.ch,breakingpitt.es,download.example,192.168,172.16,127.0.0.1,localhost,download.rockylinux.org,cyber.gov.au,herokuapp.com,rpa.st,home.arpa,SERVER_IP,dev.mysql.com,ip_address,github.com,reddit.com/r/rockylinux,planet.i2p,linode.com,server1.rockylinux.lan,docs.rockylinux.lan,developer.download.nvidia.com,azure.microsoft.com' | |
# NOTE:(sspencerwire) 2022-10-25, cyber.gov.au added to excludes as a known good URL that will not pass the test. Probably blocking GitHub | |
# NOTE:(sspencerwire) 2024-04-23, the reddit URL and the linode.com URL function fine, and test fine in the URL checker, but then throw errors at the end. The problem has been reported to the upstream package maintainer. | |
# NOTE:(sspencerwire) 2024-09-11, a link to http://developer.download.nvidia.com/compute/cuda/repos/rhel9/$ failed. This is in a slice of code, and is actually correct, but will always fail the check. | |
# NOTE:(sspencerwire) 2024-09-11, azure.microsoft.com/en-us/ has been failing consistently, but loads fine in a browser. They are probably blocking GitHub. | |
print_all: false | |
retry_count: 2 | |
timeout: 7 | |
force_pass: true # Don't block deployment | |
save: "output.csv" | |
verbose: true | |
- name: Affected URLs | |
id: gather | |
run: | | |
OUT="$(awk -F, '((NR>1 && $2=="failed") || NR==1 ){print}' output.csv)" | |
echo 'URLS<<EOF' >> $GITHUB_OUTPUT | |
echo $OUT >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
echo "COUNT_U=$(( $(wc -l <<<$OUT) - 1 ))" >> $GITHUB_OUTPUT | |
outputs: | |
URLS: ${{ steps.gather.outputs.URLS }} | |
COUNT_U: ${{ steps.gather.outputs.COUNT_U }} | |
comment: | |
name: "Comment on PR" | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Comment | |
uses: actions/github-script@v5 | |
env: | |
URLS: "${{ needs.test.outputs.URLS }}" | |
COUNT_U: "${{ needs.test.outputs.COUNT_U }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const count_u = process.env.COUNT_U.toString(); | |
const commentText = 'Test results for ' + context.payload.pull_request.head.sha + ":\n\nNumber of broken URLs: " + count_u + "\n"; | |
const output = process.env.URLS.toString().trimEnd(); | |
var body = "<details>\n<summary>" + commentText + "</summary>\n\n```csv\n" + output + "\n```\n\n</details>"; | |
const fs = require('fs'); | |
fs.writeFileSync(process.env.GITHUB_STEP_SUMMARY, body); | |
needNewComment = true; | |
console.log('Reviewing existing comments...'); | |
for await (const { data: comments } of github.paginate.iterator( | |
github.rest.issues.listComments, | |
{ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
} | |
)) { | |
for (const comment of comments) { | |
if (comment.user.login === 'github-actions[bot]') { | |
if (needNewComment && comment.body.includes(commentText)) { | |
needNewComment = false; | |
} else { | |
console.log('Deleting comment: ' + comment.id); | |
await github.rest.issues.deleteComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: comment.id, | |
}); | |
} | |
} | |
} | |
} | |
if (needNewComment) { | |
console.log('Creating new comment...'); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
body: body, | |
}); | |
} |