Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: migrate from npm & lerna bootstrap to pnpm #1047

Merged
merged 11 commits into from
Feb 7, 2023
Merged
11 changes: 7 additions & 4 deletions .github/actions/release-alpha/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ runs:
git config --local user.email "[email protected]"
git config --local user.name "empathy/x"
shell: bash
- name: Configure npm auth

- name: Configure pnpm auth
run: |
npm config set registry="https://registry.npmjs.org/"
npm config set _authToken=${NPM_TOKEN}
pnpm config set registry="https://registry.npmjs.org/"
pnpm config set _authToken=${NPM_TOKEN}
shell: bash
env:
NPM_TOKEN: ${{ inputs.npm_token }}

- name: Publish release
run: npm run release:alpha
run: pnpm run release:alpha
shell: bash

- name: Push tags
uses: ad-m/github-push-action@master
with:
Expand Down
66 changes: 44 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,63 @@ jobs:
image: cypress/browsers:node16.16.0-chrome105-ff104-edge
# https://github.com/cypress-io/github-action#firefox Cypress FF image needs this user permissions to be able to install dependencies
options: --user 1001

steps:
- uses: actions/checkout@v3
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
# Using lerna, it is recommended to cache the whole node_modules folder https://github.com/actions/cache/blob/main/examples.md#node---lerna
# but this is not the standard, normally, only the node_modules/.cache should be cached. Also, as cypress image is used, node is already
# preinstalled, the expected action `setup-node` is not used.
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#about-caching-workflow-dependencies
- name: Cache node modules
id: cache-node-modules

# Install pnpm because it is not included in our container image
- name: install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: save pnpm store directory
id: pnpm-store-directory
shell: bash
run: |
echo "PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: setup pnpm cache
id: pnpm-cache
uses: actions/cache@v3
with:
path: |
**/node_modules
${{ steps.pnpm-store-directory.outputs.PATH }}
~/.cache/Cypress
key: node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Cache eslint
id: cache-eslint
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: setup lerna cache
id: lerna-cache
uses: actions/cache@v3
with:
path: |
node_modules/.cache
key: lerna-cache-${{github.sha}}
restore-keys: lerna-cache-

- name: setup eslint cache
uses: actions/cache@v3
with:
path: .eslintcache
key: eslint-${{github.sha}}
restore-keys: eslint-
- name: Install lerna and all packages
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Build
if: steps.cache-node-modules.outputs.cache-hit == 'true'
run: npm run build
- name: Run linter in all packages
run: npm run lint
- name: Run tests in all packages
run: npm run test
- name: Release alpha on non-release pushes to main branch

- name: install dependencies
run: pnpm install

- name: lint packages
run: pnpm run lint

- name: test packages
run: pnpm run test

- name: release alpha on non-release pushes to main branch
if:
${{ github.ref_name == 'main' && github.actor != 'support-empathy' &&
!startsWith(github.event.head_commit.message, 'chore(release):') }}
Expand Down
33 changes: 23 additions & 10 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,36 @@ jobs:
image: cypress/browsers:node16.16.0-chrome105-ff104-edge
# https://github.com/cypress-io/github-action#firefox Cypress FF image needs this user permissions to be able to install dependencies
options: --user 1001

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install lerna and all packages
run: npm ci
- name: Run linter in all packages
run: npm run lint
- name: Run tests in all packages
run: npm run test
- name: Configure git user

# Install pnpm because it is not included in our container image
- name: install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: install dependencies
run: pnpm install

- name: lint packages
run: pnpm run lint

- name: test packages
run: pnpm run test

- name: configure git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "empathy/x"
- name: Prepare the release
run: npm run prepare-release:stable
- name: Create Pull Request

- name: prepare the release
run: pnpm run prepare-release:stable

- name: create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.SUPPORT_TOKEN }}
Expand Down
38 changes: 26 additions & 12 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,44 @@ jobs:
image: cypress/browsers:node16.16.0-chrome105-ff104-edge
# https://github.com/cypress-io/github-action#firefox Cypress FF image needs this user permissions to be able to install dependencies
options: --user 1001

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Install lerna and all packages
run: npm ci
- name: Run linter in all packages
run: npm run lint
- name: Run tests in all packages
run: npm run test
- name: Configure git user

# Install pnpm because it is not included in our container image
- name: install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: install dependencies
run: pnpm install

- name: lint packages
run: pnpm run lint

- name: test packages
run: pnpm run test

- name: configure git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "empathy/x"
- name: Configure npm auth

- name: configure pnpm auth
run: |
npm config set registry="https://registry.npmjs.org/"
npm config set _authToken=${NPM_TOKEN}
pnpm config set registry="https://registry.npmjs.org/"
pnpm config set _authToken=${NPM_TOKEN}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish the release

- name: publish the release
run: npm run publish-release
- name: Push tags

- name: push tags
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SUPPORT_TOKEN }}
Expand Down
28 changes: 20 additions & 8 deletions .github/workflows/release-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@ jobs:
image: cypress/browsers:node16.16.0-chrome105-ff104-edge
# https://github.com/cypress-io/github-action#firefox Cypress FF image needs this user permissions to be able to install dependencies
options: --user 1001

steps:
- uses: actions/checkout@v3
- name: checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Install lerna and all packages
run: npm ci
- name: Run linter in all packages
run: npm run lint
- name: Run tests in all packages
run: npm run test
- name: Call release alpha action

# Install pnpm because it is not included in our container image
- name: install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: install dependencies
run: pnpm install

- name: lint packages
run: pnpm run lint

- name: test packages
run: pnpm run test

- name: execute release-alpha action
uses: ./.github/actions/release-alpha
with:
npm_token: ${{ secrets.NPM_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.env.*.local

# Log files
pnpm-debug.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Enable pre and post scripts due to pnpm not running them by default
enable-pre-post-scripts=true
engine-strict=true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ To prepare your development environment, proceed as follows:

1. Fork the X repository and then clone it to your local environment:
`git clone https://github.com/empathyco/x.git`.
2. Install the dependencies in the root folder: `npm install`. This links all the projects.
3. Run a build so that the linked projects work: `npm run build`.
2. Install the dependencies in the root folder: `pnpm install --frozen-lockfile`. This links all the
projects.

Have a look to
[this article](https://medium.com/empathyco/moving-to-a-mono-repo-part-1-the-journey-eb63efd8ef64)
Expand Down
12 changes: 4 additions & 8 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"packages": ["packages/*"],
"version": "independent",
"ignoreChanges": ["**/package-lock.json"],
"ignoreChanges": ["pnpm-lock.yaml"],
"changelogPreset": {
"name": "conventionalcommits",
"issuePrefixes": ["EX-"],
Expand All @@ -21,13 +20,10 @@
]
},
"command": {
"bootstrap": {
"npmClientArgs": ["--legacy-peer-deps"],
"hoist": true,
"strict": true
},
"version": {
"message": "chore(release): publish"
}
}
},
"npmClient": "pnpm",
"useWorkspaces": true
}
9 changes: 7 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist", "{projectRoot}/showcase"]
"dependsOn": ["^build", "prebuild"],
"outputs": [
"{projectRoot}/dist",
"{projectRoot}/showcase",
"{projectRoot}/types",
"{projectRoot}/report"
]
}
}
}
Loading