Skip to content

Commit

Permalink
Detect if new changes break existing links
Browse files Browse the repository at this point in the history
Added a unit test which determines if any static links have been broken by iterating over the build output and comparing it to a snapshot of existing links. The test will fail if a page is removed and no redirect is added for it.
  • Loading branch information
AndyClifford committed Oct 8, 2023
1 parent 7d435ec commit ee66876
Show file tree
Hide file tree
Showing 11 changed files with 1,007 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ jobs:
- run: yarn test
- run: ./build.sh
- run: yarn linkinator
- run: yarn integration
3 changes: 3 additions & 0 deletions Dockerfile.integration
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM node:18-alpine

RUN apk add rsync
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ To build and preview Centrapay Docs using the static files that are deployed to
docker compose run script yarn build
docker compose run script yarn preview
```

## Integration Tests

```
docker compose run script yarn build --mode development
docker compose run ruby-script bundle exec jekyll build
docker compose run integration yarn integration
```
2 changes: 2 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
volumes: [ node-modules:/work/node_modules ]
script:
volumes: [ node-modules:/work/node_modules ]
integration:
volumes: [ node-modules:/work/node_modules ]
legacy:
volumes: [ bundle:/usr/local/bundle ]
ruby-script:
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ services:
echo "
To execute a script, run:
docker-compose run ruby-script {command}"
integration:
build:
context: .
dockerfile: Dockerfile.integration
init: true
working_dir: /work
volumes: [ ".:/work" ]
command: |
echo '
Skipping integration tests. To execute integration tests, run:
docker compose run integration yarn integration'
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"test": "vitest --watch=false"
"test": "vitest --watch=false",
"integration": "rsync -a dist/* _site/ && vitest --watch=false --config vitest.integration.config.js"
},
"devDependencies": {
"@astrojs/mdx": "^1.0.3",
Expand All @@ -32,6 +33,7 @@
"linkinator": "^5.0.2",
"mdast-util-to-string": "^3.1.1",
"mermaid": "^9.3.0",
"path": "^0.12.7",
"remark-html": "^15.0.2",
"remark-parse": "^10.0.1",
"remark-sectionize": "^1.1.1",
Expand All @@ -40,6 +42,7 @@
"unist-util-find-after": "^4.0.1",
"unist-util-visit": "^4.1.2",
"vitest": "^0.28.3",
"vue": "^3.2.47"
"vue": "^3.2.47",
"jsdom": "^22.1.0"
}
}
Loading

0 comments on commit ee66876

Please sign in to comment.