Skip to content

Commit 4fc59ae

Browse files
workin
1 parent 60ab189 commit 4fc59ae

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

.github/workflows/test-pr.yml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ on:
66
types: [opened, reopened, synchronize]
77

88
env:
9+
# The folder with the doc files
10+
DOCS_FOLDER: 'docs'
911
# The folder that Docusaurus hosts static files (images) from
1012
STATIC_FOLDER: 'static'
1113
# Images to ignore for image use checks
1214
IGNORE_IMAGES: 'img/site'
15+
# The folder that the tests repo is cloned to
16+
TEST_REPO: 'doclib'
1317

1418
jobs:
1519

1620
# Get files that are added or changed in this PR
21+
# Provides the files as a comma-separated list
1722
getChangedFiles:
1823
runs-on: ubuntu-latest
1924
outputs:
@@ -29,29 +34,23 @@ jobs:
2934
docs/**/*.md
3035
docs/**/*.mdx
3136
32-
- name: List all changed files
33-
env:
34-
ALL_CHANGED_FILES: ${{ steps.changed-markdown-files.outputs.all_changed_files }}
35-
run: |
36-
for file in ${ALL_CHANGED_FILES}; do
37-
echo "$file was changed"
38-
done
39-
40-
# Test the changed files
41-
test:
37+
# Clone the doc repo to test
38+
cloneDocRepo:
4239
runs-on: ubuntu-latest
43-
needs: getChangedFiles
44-
if: ${{ needs.getChangedFiles.outputs.files != '' }}
4540
steps:
46-
# Clone the repo and install dependencies
41+
# Clone the repo and install dependencies
4742
- uses: actions/checkout@v2
4843
- uses: actions/setup-node@v1
4944
with:
5045
node-version: 20
5146
# - run: npm ci
5247

53-
# Clone tests from https://gitlab.com/nomadic-labs/doclib
54-
# Uses https://github.com/marketplace/actions/any-clone-repo
48+
# Clone and set up repo with doc tests
49+
setUpTests:
50+
runs-on: ubuntu-latest
51+
# Clone tests from https://gitlab.com/nomadic-labs/doclib
52+
# Uses https://github.com/marketplace/actions/any-clone-repo
53+
steps:
5554
- name: Clone test repo
5655
uses: chihqiang/checkout-action@main
5756
with:
@@ -62,8 +61,20 @@ jobs:
6261
working-directory: doclib
6362
run : npm ci
6463

64+
# Test the changed files
65+
test:
66+
runs-on: ubuntu-latest
67+
needs: [getChangedFiles, setUpTests, cloneDocRepo]
68+
if: ${{ needs.getChangedFiles.outputs.files != '' }}
69+
steps:
70+
6571
# Run tests
66-
- name: Run used image check
72+
- name: Run image link check
6773
working-directory: doclib
68-
run: npm run usedImages -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} --imageFolder=${{ env.STATIC_FOLDER }}
74+
# Here, --docFiles is the list of changed files so the test checks the links to images in only those files
75+
run: npm run imageLinks -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} --imageFolder=${{ env.STATIC_FOLDER }}
6976

77+
- name: Run unused image check
78+
working-directory: doclib
79+
# Here, --docFiles is the folder where all of the doc files are so the test can check that no images have become abandoned
80+
run: npm run usedImages -- --baseFolder=${{ github.workspace }} --docFiles=${{ env.DOCS_FOLDER }} --imageFolder=${{ env.STATIC_FOLDER }} --ignoreImages=${{ env.IGNORE_IMAGES }}

0 commit comments

Comments
 (0)