diff --git a/.github/workflows/lint-build-test.yml b/.github/workflows/lint-build-test.yml index d11be3b1744..8fc8ce51afb 100644 --- a/.github/workflows/lint-build-test.yml +++ b/.github/workflows/lint-build-test.yml @@ -10,6 +10,8 @@ jobs: strategy: matrix: node-version: [14.x, 16.x] + outputs: + child-workspace-package-names: ${{ steps.workspace-package-names.outputs.child-workspace-package-names }} steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} @@ -18,6 +20,11 @@ jobs: node-version: ${{ matrix.node-version }} cache: yarn - run: yarn --immutable + - name: Fetch workspace package names + id: workspace-package-names + run: | + echo "child-workspace-package-names=$(yarn child-workspace-package-names-as-json)" >> "$GITHUB_OUTPUT" + shell: bash lint: name: Lint @@ -35,7 +42,31 @@ jobs: cache: yarn - run: yarn --immutable --immutable-cache - run: yarn lint - - run: yarn changelog:validate + - name: Require clean working directory + shell: bash + run: | + if ! git diff --exit-code; then + echo "Working tree dirty at end of job" + exit 1 + fi + + validate-changelog: + name: Validate changelog + runs-on: ubuntu-latest + needs: prepare + strategy: + matrix: + node-version: [14.x, 16.x] + package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }} + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: yarn + - run: yarn --immutable --immutable-cache + - run: yarn workspace ${{ matrix.package-name }} changelog:validate - name: Require clean working directory shell: bash run: | @@ -75,6 +106,7 @@ jobs: strategy: matrix: node-version: [14.x, 16.x] + package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }} steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} @@ -83,7 +115,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: yarn - run: yarn --immutable --immutable-cache - - run: yarn test + - run: yarn workspace ${{ matrix.package-name }} run test - name: Require clean working directory shell: bash run: | diff --git a/package.json b/package.json index 48dc9256548..e0645537e11 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "build:docs": "yarn workspaces foreach --parallel --interlaced --verbose run build:docs", "build:watch": "yarn run build --watch", "changelog:validate": "yarn workspaces foreach --parallel --interlaced --verbose run changelog:validate", + "child-workspace-package-names-as-json": "ts-node scripts/child-workspace-package-names-as-json.ts", "generate-dependency-graph": "ts-node scripts/generate-dependency-graph.ts", "lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints", "lint:eslint": "eslint . --cache --ext js,ts", diff --git a/scripts/child-workspace-package-names-as-json.ts b/scripts/child-workspace-package-names-as-json.ts new file mode 100755 index 00000000000..3f82125d39c --- /dev/null +++ b/scripts/child-workspace-package-names-as-json.ts @@ -0,0 +1,20 @@ +#!yarn ts-node + +import execa from 'execa'; + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); + +/** + * The entrypoint to this script. + */ +async function main() { + const { stdout } = await execa('yarn', ['workspaces', 'list', '--json']); + const workspaces = stdout.split('\n').map((line) => JSON.parse(line)); + const childWorkspaceNames = workspaces + .filter((workspace) => workspace.location !== '.') + .map((workspace) => workspace.name); + console.log(JSON.stringify(childWorkspaceNames)); +}