Skip to content

Commit 2f94989

Browse files
workin
1 parent 60ab189 commit 2f94989

1 file changed

Lines changed: 36 additions & 26 deletions

File tree

.github/workflows/test-pr.yml

Lines changed: 36 additions & 26 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,41 +34,46 @@ 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
55-
- name: Clone test repo
56-
uses: chihqiang/checkout-action@main
57-
with:
58-
repo: https://gitlab.com/nomadic-labs/doclib.git
59-
branch: main
60-
dest: doclib
61-
- name: Install test repo dependencies
62-
working-directory: doclib
63-
run : npm ci
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+
- name: Clone test repo
54+
uses: chihqiang/checkout-action@main
55+
with:
56+
repo: https://gitlab.com/nomadic-labs/doclib.git
57+
branch: main
58+
dest: doclib
59+
- name: Install test repo dependencies
60+
working-directory: doclib
61+
run : npm ci
62+
63+
# Test the changed files
64+
test:
65+
runs-on: ubuntu-latest
66+
needs: [getChangedFiles, setUpTests, cloneDocRepo]
67+
if: ${{ needs.getChangedFiles.outputs.files != '' }}
68+
steps:
6469

6570
# Run tests
66-
- name: Run used image check
71+
- name: Run image link check
6772
working-directory: doclib
68-
run: npm run usedImages -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} --imageFolder=${{ env.STATIC_FOLDER }}
73+
# Here, --docFiles is the list of changed files so the test checks the links to images in only those files
74+
run: npm run imageLinks -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} --imageFolder=${{ env.STATIC_FOLDER }}
6975

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

0 commit comments

Comments
 (0)