Update en.md #8
Workflow file for this run
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: osu-wiki continuous integration | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- edited | |
jobs: | |
ci: | |
name: changed files | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: detect changed files | |
run: | | |
INTERESTING_FILES=$( | |
sort -u < <( | |
# Changes committed so far (may overlap with the above) | |
git diff --no-renames --name-only --diff-filter=d ${{ github.sha }}^ | |
) | |
) | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings | |
# XXX: env.INTERESTING_FILES will be a single string with newline delimiters. | |
DELIMITER="X${RANDOM}" | |
echo "INTERESTING_FILES<<${DELIMITER}" >> $GITHUB_ENV | |
echo "${INTERESTING_FILES}" >> $GITHUB_ENV | |
echo "${DELIMITER}" >> $GITHUB_ENV | |
- name: inspect file sizes | |
shell: bash | |
run: | | |
readarray -t TARGET_FILES <<< "${{ env.INTERESTING_FILES }}" | |
bash scripts/ci/inspect_file_sizes.sh --target "${TARGET_FILES[@]}" | |
- name: set up Node.js | |
id: setup-node | |
uses: actions/setup-node@v3 | |
with: | |
cache: npm | |
node-version: 16 | |
- name: load node_modules from cache | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }}-${{ steps.setup-node.outputs.node-version }} | |
- name: install remark | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: run remark on changed files | |
run: | | |
readarray -t REMARK_TARGET_FILES <<< $( | |
# ppy/osu-wiki#8867 -- disable style checks for non-article Markdown files, such as README.md | |
echo "${{ env.INTERESTING_FILES }}" | grep -e .md$ | grep -E -v '^[A-Z-]+\.md$' || true | |
) | |
bash scripts/ci/run_remark.sh --target "${REMARK_TARGET_FILES[@]}" | |
- name: set up Python | |
uses: actions/setup-python@v4 | |
with: | |
cache: pip | |
cache-dependency-path: scripts/requirements.txt | |
python-version: 3.x | |
- name: set up Python CI dependencies | |
run: pip install -r scripts/requirements.txt | |
- name: run yamllint on .yaml and .md files | |
run: | | |
readarray -t YAMLLINT_TARGET_FILES <<< $( echo "${{ env.INTERESTING_FILES }}" | grep -e .yaml$ -e .yml$ -e .md$ || true ) | |
osu-wiki-tools check-yaml --config .yamllint.yaml --target "${YAMLLINT_TARGET_FILES[@]}" | |
- name: find broken wikilinks | |
shell: bash | |
env: | |
PULL_REQUEST_TAG: 'SKIP_WIKILINK_CHECK' | |
run: | | |
if ${{ contains(github.event.pull_request.body, env.PULL_REQUEST_TAG) }}; then | |
echo "::notice::Broken wikilink check suppressed ($PULL_REQUEST_TAG tag found in the pull request)" | |
exit 0 | |
fi | |
readarray -t WIKILINK_TARGET_FILES <<< $( echo "${{ env.INTERESTING_FILES }}" | grep -e ^wiki/ -e ^news/ | grep .md$ || true ) | |
osu-wiki-tools check-links --target "${WIKILINK_TARGET_FILES[@]}" | |
- name: check if translations are marked as outdated | |
shell: bash | |
env: | |
PULL_REQUEST_TAG: 'SKIP_OUTDATED_CHECK' | |
run: | | |
if ${{ contains(github.event.pull_request.body, env.PULL_REQUEST_TAG) }}; then | |
echo "::notice::Outdated articles check suppressed ($PULL_REQUEST_TAG tag found in the pull request)" | |
exit 0 | |
fi | |
MAX_ATTEMPTS=3 | |
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do | |
# get the first commit of the branch associated with the PR; GitHub's ubuntu-latest has curl/jq: https://github.com/actions/virtual-environments | |
API_RESPONSE=$( | |
curl -sS --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
${{ github.event.pull_request.commits_url }}?per_page=1 | |
) | |
if [[ 'array' != $( echo "${API_RESPONSE}" | jq -r 'type' ) ]]; then | |
echo "::warning::Unexpected GitHub API response (attempt ${i}/${MAX_ATTEMPTS}): ${API_RESPONSE}" | |
else | |
FIRST_PR_COMMIT_HASH=$( echo "${API_RESPONSE}" | jq -r '.[0].sha' ) | |
osu-wiki-tools check-outdated-articles --workflow --base-commit ${{ github.sha }} --outdated-since $FIRST_PR_COMMIT_HASH | |
exit $? | |
fi | |
done | |
echo "::warning::Failed to read the hash of the PR's first commit -- please check why that happened" | |
exit 1 |