Skip to content

Commit

Permalink
ci: updated nx CI workflow and node engine version
Browse files Browse the repository at this point in the history
* bumped node engine version in all package.json and CI files

* manually specified node-version in CI workflow

* bumped node-version for nx agents

* added PR-specific workflow file

* removed nx agent distribution

* updated dep install command

* ran nx format

* re-added nx-plus/docusaurus

* re-added nx agent distribution

* removed nx agent distribution in favor of no agents

* updated main CI workflow file

* ran nx format
  • Loading branch information
wgd3 authored Feb 20, 2024
1 parent 02fb3b1 commit 0da7c91
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 58 deletions.
9 changes: 2 additions & 7 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"projectOwner": "@nx-fullstack",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"files": ["README.md"],
"imageSize": 100,
"commit": true,
"commitConvention": "conventional",
Expand All @@ -15,10 +13,7 @@
"name": "Wallace Daniel",
"avatar_url": "https://avatars.githubusercontent.com/u/5431570?v=4",
"profile": "https://thefullstack.engineer/",
"contributions": [
"code",
"projectManagement"
]
"contributions": ["code", "projectManagement"]
}
],
"contributorsPerLine": 7
Expand Down
86 changes: 54 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
name: CI
name: Main CI

on:
push:
branches:
- main
pull_request:
# pull_request:

jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/[email protected]
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
main-branch-name: main
number-of-agents: 3
init-commands: |
yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
yarn nx-cloud record -- yarn nx format:check
parallel-commands-on-agents: |
yarn nx lint harbor-master
yarn nx test harbor-master --ci --codeCoverage
yarn nx build harbor-master
artifacts-path: |
dist
coverage
package.json
artifacts-name: dist-and-coverage-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'

- run: npx nx-cloud start-ci-run
- run: yarn install --frozen-lockfile

- uses: nrwl/nx-set-shas@v3

- run: npx nx-cloud record -- nx format:check
- run: npx nx run-many -t lint test build --no-agents

# main:
# name: Nx Cloud - Main Job
# uses: nrwl/ci/.github/workflows/[email protected]
# secrets:
# NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# with:
# main-branch-name: main
# number-of-agents: 3
# init-commands: |
# yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
# parallel-commands: |
# yarn nx-cloud record -- yarn nx format:check
# parallel-commands-on-agents: |
# yarn nx lint harbor-master
# yarn nx test harbor-master --ci --codeCoverage
# yarn nx build harbor-master
# artifacts-path: |
# dist
# coverage
# package.json
# artifacts-name: dist-and-coverage-artifacts
# node-version: '20'

agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/[email protected]
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
number-of-agents: 3
# agents:
# name: Nx Cloud - Agents
# uses: nrwl/ci/.github/workflows/[email protected]
# secrets:
# NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# with:
# number-of-agents: 3
# node-version: '20'

release:
runs-on: ubuntu-latest
Expand All @@ -55,7 +77,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'

- run: yarn install --frozen-lockfile

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
cache: 'npm'

- name: Install deps
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Pull Request CI

on:
pull_request:

# Needed for nx-set-shas when run on the main branch
permissions:
actions: read
contents: read

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'

- run: npx nx-cloud start-ci-run
- run: yarn install --frozen-lockfile

- uses: nrwl/nx-set-shas@v3
# This line is needed for nx affected to work when CI is running on a PR
- run: git branch --track main origin/main

- run: npx nx-cloud record -- nx format:check
- run: npx nx affected -t lint test build --no-agents
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'

- run: yarn install --frozen-lockfile

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Thumbs.db
# nx
migrations.json
.nx/cache
nx-cloud.env

# Generated Docusaurus files
.docusaurus/
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
## [1.0.3](https://github.com/nxfullstack/harbor-master/compare/v1.0.2...v1.0.3) (2023-04-11)


### CI/CD

* more package.json fixes ([824a56e](https://github.com/nxfullstack/harbor-master/commit/824a56ee53544d355423bf9e79fd3b73580e1ffc))
- more package.json fixes ([824a56e](https://github.com/nxfullstack/harbor-master/commit/824a56ee53544d355423bf9e79fd3b73580e1ffc))

## [1.0.2](https://github.com/nxfullstack/harbor-master/compare/v1.0.1...v1.0.2) (2023-04-11)

Expand Down
4 changes: 2 additions & 2 deletions docs/doc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (!fs.existsSync(outputPath)) {

for (const [category, items] of Object.entries(categories)) {
let md = `---\nslug: /harbor-master/${category.toLowerCase()}\n---\n\n# ${capitalize(
category
category,
)}\n\n`;

md += items
Expand All @@ -61,7 +61,7 @@ function getDocsSection({ name, description, examples }) {
const header = `### \`\`\`${name}\`\`\``;
const sectionText = `${description}`;
const usageText = `\`\`\`shell\n$ npm i -D @nx-fullstack/harbor-master\n\n${examples.join(
'\n'
'\n',
)}\n\`\`\``;

section += header;
Expand Down
12 changes: 6 additions & 6 deletions e2e/harbor-master-e2e/tests/harbor-master.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('harbor-master e2e', () => {
beforeAll(() => {
ensureNxProject(
'@nx-fullstack/harbor-master',
'dist/packages/harbor-master'
'dist/packages/harbor-master',
);
});

Expand All @@ -29,7 +29,7 @@ describe('harbor-master e2e', () => {
it('should create harbor-master', async () => {
const project = uniq('harbor-master');
await runNxCommandAsync(
`generate @nx-fullstack/harbor-master:lib ${project}`
`generate @nx-fullstack/harbor-master:lib ${project}`,
);
const result = await runNxCommandAsync(`build ${project}`);
expect(result.stdout).toContain('Executor ran');
Expand All @@ -39,10 +39,10 @@ describe('harbor-master e2e', () => {
it('should create src in the specified directory', async () => {
const project = uniq('harbor-master');
await runNxCommandAsync(
`generate @nx-fullstack/harbor-master:lib ${project} --directory subdir`
`generate @nx-fullstack/harbor-master:lib ${project} --directory subdir`,
);
expect(() =>
checkFilesExist(`libs/subdir/${project}/src/index.ts`)
checkFilesExist(`libs/subdir/${project}/src/index.ts`),
).not.toThrow();
}, 120000);
});
Expand All @@ -52,10 +52,10 @@ describe('harbor-master e2e', () => {
const projectName = uniq('harbor-master');
ensureNxProject(
'@nx-fullstack/harbor-master',
'dist/packages/harbor-master'
'dist/packages/harbor-master',
);
await runNxCommandAsync(
`generate @nx-fullstack/harbor-master:lib ${projectName} --tags e2etag,e2ePackage`
`generate @nx-fullstack/harbor-master:lib ${projectName} --tags e2etag,e2ePackage`,
);
const project = readJson(`libs/${projectName}/project.json`);
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@commitlint/cli": "18.6.1",
"@commitlint/config-conventional": "18.6.2",
"@docusaurus/module-type-aliases": "2.1.0",
"@nx-plus/docusaurus": "^15.0.0-rc.0",
"@nx/devkit": "18.0.4",
"@nx/eslint": "18.0.4",
"@nx/eslint-plugin": "18.0.4",
Expand Down Expand Up @@ -67,6 +68,9 @@
"react-dom": "^17.0.2",
"tslib": "^2.6.2"
},
"engines": {
"node": ">=20.8.1"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
Expand Down
2 changes: 1 addition & 1 deletion packages/harbor-master/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"license": "MIT",
"engines": {
"node": "^16.0.0 || >= 18.0.0"
"node": ">=20.8.1"
},
"main": "src/index.js",
"generators": "./generators.json",
Expand Down
6 changes: 3 additions & 3 deletions packages/harbor-master/src/generators/library/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface NormalizedSchema extends HarborMasterGeneratorSchema {

function normalizeOptions(
tree: Tree,
options: HarborMasterGeneratorSchema
options: HarborMasterGeneratorSchema,
): NormalizedSchema {
const name = names(options.name).fileName;
const projectDirectory = options.directory
Expand Down Expand Up @@ -52,7 +52,7 @@ function addFiles(tree: Tree, options: NormalizedSchema) {
tree,
path.join(__dirname, 'files'),
options.projectRoot,
templateOptions
templateOptions,
);
}

Expand All @@ -79,7 +79,7 @@ function addFiles(tree: Tree, options: NormalizedSchema) {
*/
export default async function (
tree: Tree,
options: HarborMasterGeneratorSchema
options: HarborMasterGeneratorSchema,
) {
const normalizedOptions = normalizeOptions(tree, options);
addProjectConfiguration(tree, normalizedOptions.projectName, {
Expand Down
4 changes: 1 addition & 3 deletions packages/harbor-master/src/generators/library/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@
"description": "A directory where the project is placed"
}
},
"required": [
"name"
]
"required": ["name"]
}
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,17 @@
dependencies:
"@nx/devkit" "18.0.4"

"@nrwl/devkit@^15.0.0":
version "15.9.7"
resolved "https://registry.yarnpkg.com/@nrwl/devkit/-/devkit-15.9.7.tgz#14d19ec82ff4209c12147a97f1cdea05d8f6c087"
integrity sha512-Sb7Am2TMT8AVq8e+vxOlk3AtOA2M0qCmhBzoM1OJbdHaPKc0g0UgSnWRml1kPGg5qfPk72tWclLoZJ5/ut0vTg==
dependencies:
ejs "^3.1.7"
ignore "^5.0.4"
semver "7.5.4"
tmp "~0.2.1"
tslib "^2.3.0"

"@nrwl/[email protected]":
version "18.0.4"
resolved "https://registry.yarnpkg.com/@nrwl/eslint-plugin-nx/-/eslint-plugin-nx-18.0.4.tgz#b9cef2b6f0075a17e93f11f99301b0c44f3e06d3"
Expand Down Expand Up @@ -3431,6 +3442,13 @@
dependencies:
"@nx/workspace" "18.0.4"

"@nx-plus/docusaurus@^15.0.0-rc.0":
version "15.0.0-rc.0"
resolved "https://registry.yarnpkg.com/@nx-plus/docusaurus/-/docusaurus-15.0.0-rc.0.tgz#3233637ed3678d7be491ee3c2f9fb3c6ca407f25"
integrity sha512-GmoYHKljQJvJLSYhWBe+huStwJbm+RbK+lC2j2sA+ZCUdkUo+P2Yv5oQGbqWU4jXclYe8pOP/qVFJs3j3Zjw/Q==
dependencies:
"@nrwl/devkit" "^15.0.0"

"@nx/[email protected]":
version "18.0.4"
resolved "https://registry.yarnpkg.com/@nx/devkit/-/devkit-18.0.4.tgz#fec28139ef5d078933c5f1b5a7e0a585672dbdd6"
Expand Down Expand Up @@ -13762,6 +13780,13 @@ semver-truncate@^2.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

[email protected]:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

[email protected], semver@^7.5.2, semver@^7.5.3, semver@^7.5.4:
version "7.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
Expand Down

0 comments on commit 0da7c91

Please sign in to comment.