Skip to content

Commit

Permalink
feat(repo): fix failing yarn and pnpm (nrwl#5782)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored May 26, 2021
1 parent ce6f7f2 commit 9e47d96
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
42 changes: 34 additions & 8 deletions .github/workflows/e2e-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: E2E matrix
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

jobs:
e2e:
Expand All @@ -13,8 +19,8 @@ jobs:
- ubuntu-latest
# - windows-latest
node_version:
- 14.x
# - 15.x
- '14'
# - '15'
package_manager:
- npm
- yarn
Expand All @@ -31,20 +37,33 @@ jobs:
- e2e-angular
fail-fast: false

name: Node v${{ matrix.node_version }} (${{ matrix.package_manager }}) - ${{ matrix.packages }}
name: ${{ matrix.os }}/node v${{ matrix.node_version }}/${{ matrix.package_manager }} - ${{ matrix.packages }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install dependencies
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}

- name: Yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ matrix.os }}-node-${{ matrix.node-version }}-yarn-

- run: yarn install

- name: Cleanup
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
# Workaround to provide additional free space for testing.
# https://github.com/actions/virtual-environments/issues/2840
Expand All @@ -55,18 +74,25 @@ jobs:
- name: Install PNPM
if: ${{ matrix.package_manager == 'pnpm' }}
uses: pnpm/action-setup@v2.0.1
uses: pnpm/action-setup@v1.2.1
with:
version: 6.0.2
version: 5.18.9

- name: Run e2e tests
run: yarn nx run-many --target=e2e --projects=${{ matrix.packages }}
run: yarn nx run-many --target=e2e --projects="${{ join(matrix.packages) }}"
env:
GIT_AUTHOR_NAME: [email protected]
GIT_AUTHOR_EMAIL: Test
GIT_COMMITTER_EMAIL: [email protected]
GIT_COMMITTER_NAME: Test
NX_E2E_CI_CACHE_KEY: e2e-gha-${{ matrix.node_version }}-${{ matrix.package_manager }}
NX_E2E_CI_CACHE_KEY: e2e-gha-${{ matrix.os }}-${{ matrix.node_version }}-${{ matrix.package_manager }}
NODE_OPTIONS: --max_old_space_size=8192
SELECTED_PM: ${{ matrix.package_manager }}
YARN_REGISTRY: http://localhost:4872
SELECTED_CLI: ${{ matrix.packages == 'e2e-angular' && 'angular' || 'nx' }}

- name: Setup tmate session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled && failure() }}
uses: mxschmitt/action-tmate@v3
with:
sudo: ${{ matrix.os != 'windows-latest' }} # disable sudo for windows debugging
8 changes: 5 additions & 3 deletions e2e/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,24 +521,26 @@ export function getPackageManagerCommand({
? ' --scripts-prepend-node-path '
: '';

const publishedVersion = `9999.0.2`;

return {
npm: {
createWorkspace: `npx create-nx-workspace@9999.0.2`,
createWorkspace: `npx create-nx-workspace@${publishedVersion}`,
runNx: `npm run nx${scriptsPrependNodePathFlag} --`,
runNxSilent: `npm run nx --silent${scriptsPrependNodePathFlag} --`,
addDev: `npm install --legacy-peer-deps -D`,
list: 'npm ls --depth 10',
},
yarn: {
// `yarn create nx-workspace` is failing due to wrong global path
createWorkspace: `yarn global add create-nx-workspace@9999.0.2 && create-nx-workspace`,
createWorkspace: `yarn global add create-nx-workspace@${publishedVersion} && create-nx-workspace`,
runNx: `yarn nx`,
runNxSilent: `yarn --silent nx`,
addDev: `yarn add -D`,
list: 'npm ls --depth 10',
},
pnpm: {
createWorkspace: `pnpx create-nx-workspace@9999.0.2`,
createWorkspace: `pnpx create-nx-workspace@${publishedVersion}`,
runNx: `pnpm run nx --`,
runNxSilent: `pnpm run nx --silent --`,
addDev: `pnpm add -D`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"check-versions": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-versions.ts",
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
"e2e-start-local-registry": "node ./scripts/e2e-start-local-registry.js",
"e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json scripts/e2e-build-package-publish.ts",
"e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json ./scripts/e2e-build-package-publish.ts",
"format": "nx format",
"nx-release": "./scripts/nx-release.js",
"depcheck": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/depcheck",
Expand Down
4 changes: 2 additions & 2 deletions scripts/e2e-build-package-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ process.env.PUBLISHED_VERSION = `9999.0.2`;
process.env.npm_config_registry = `http://localhost:4872`;
process.env.YARN_REGISTRY = process.env.npm_config_registry;

export function buildPackagePublishAndCleanPorts() {
function buildPackagePublishAndCleanPorts() {
removeSync('./build');
removeSync('./tmp/nx/proj-backup');
removeSync('./tmp/angular/proj-backup');
Expand All @@ -25,7 +25,7 @@ export function buildPackagePublishAndCleanPorts() {
}
}

export const getDirectories = (source: string) =>
const getDirectories = (source: string) =>
readdirSync(source, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
Expand Down

0 comments on commit 9e47d96

Please sign in to comment.