Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
Merge f21a17d into 226d028
Browse files Browse the repository at this point in the history
  • Loading branch information
SiAdcock committed Oct 5, 2021
2 parents 226d028 + f21a17d commit 50533d0
Show file tree
Hide file tree
Showing 12 changed files with 594 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ jobs:
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn build:ci
build-packages:
validate-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: guardian/actions-setup-node@v2.4.1
with:
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn build:all
- run: yarn package-validation:validate
2 changes: 1 addition & 1 deletion docs/08-contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ $ yarn storybook
### Raising a pull request

- Don’t bump the package version as part of a pull request. Maintainers will take care of this as part of the release process.
- Test that your component can be used in a real project (e.g. [dotcom-rendering](https://github.com/guardian/dotcom-rendering) or the specially-designed [source-shakedown](https://github.com/guardian/source-shakedown)). Use [`yarn link`](https://yarnpkg.com/en/docs/cli/link) to avoid having to perform a real publish, and [`yarn pack`](https://yarnpkg.com/en/docs/cli/pack) to see exactly which files would be published.
- Test that your component can be used in a real project (e.g. [dotcom-rendering](https://github.com/guardian/dotcom-rendering)). Use [`yarn link`](https://yarnpkg.com/en/docs/cli/link) to avoid having to perform a real publish, and [`yarn pack`](https://yarnpkg.com/en/docs/cli/pack) to see exactly which files would be published.
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules', '/dist'],
testPathIgnorePatterns: [
'/node_modules',
'/dist',
'packages/@guardian/source-package-validation',
],
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"lint": "yarn lint:js && yarn lint:styles",
"lint:js": "eslint . --ext .ts,.tsx,.js",
"lint:styles": "stylelint src/core/**/styles.ts",
"package-validation": "yarn workspace @guardian/source-package-validation",
"package-validation:validate": "yarn build:all && yarn package-validation validate",
"prepare": "husky install",
"publish:release": "ts-node ./scripts/publish-release",
"publish:release:kitchen": "ts-node ./scripts/publish-release-kitchen",
Expand Down
23 changes: 23 additions & 0 deletions packages/@guardian/source-package-validation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Source Package Validation

This project is used to verify the output of the Source packages.

## How?

It runs two checks:

1. Verify that no exports have changed in the published packages

This works similar to a snapshot test in that, if anything does change, the test must be updated. This ensures that subsequent releases haven't broken the package structure or unexpectedly removed exports from the public API. It uses jest to run the test.

2. Verify that no types have been removed

This test works by importing all of the types from all packages into a file and then running `tsc`. It will capture types that have been removed but not fail when new types are added so, for now, the onus is on contributors and reviewers to **remember to add new types to this file**.

## Running locally

Validation requires all packages to be built before running.

You can run the tests including the build step by running (from the root directory): `yarn package-validation:validate`

If you are running locally and want to avoid rebuilding all packages each time then you can just rebuild the package(s) that have changed an then run: `yarn package-validation validate`
5 changes: 5 additions & 0 deletions packages/@guardian/source-package-validation/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

0 comments on commit 50533d0

Please sign in to comment.