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

chore: migrate from semver to nx release #54

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
name: Release

on:
- workflow_dispatch
push:
tags:
- v*.*.*
workflow_run:


jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # needed for provenance data generation

if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
Expand All @@ -21,20 +28,9 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_CONFIG_PROVENANCE: true
# Use npx instead of yarn because yarn automagically sets NPM_* environment variables
# like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file
# which is set up by `setup-node` action.
shell: bash
run: npx nx affected --base=last-release --target=version

- name: Tag last-release
shell: bash
run: git tag -f last-release

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
branch: ${{ github.ref }}
force: true
tags: true
run: npx nx release publish
7 changes: 6 additions & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
module.exports = {
...nxPreset,
maxWorkers: 1,
testEnvironment: 'node',
setupFiles: ['../../tools/scripts/unit-test-setup.js'],
};
29 changes: 28 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
"devTargetName": "dev",
"startTargetName": "start"
}
},
{
"plugin": "@nx/jest/plugin",
"options": {
"targetName": "test"
}
}
],
"generators": {
Expand All @@ -72,5 +78,26 @@
}
}
},
"nxCloudAccessToken": "OWEyN2E2OTktMWM2Ni00MmQwLWE1YmEtNjI2MDMwNDg1MWVjfHJlYWQtd3JpdGU="
"nxCloudAccessToken": "OWEyN2E2OTktMWM2Ni00MmQwLWE1YmEtNjI2MDMwNDg1MWVjfHJlYWQtd3JpdGU=",
"release": {
"releaseTagPattern": "v{version}",
"projects": ["nx-cloudflare"],
"projectsRelationship": "independent",
"version": {
"conventionalCommits": true,
"generatorOptions": {
"updateDependents": true
}
},
"git": {
"commit": true,
"commitArgs": "--no-verify"
},
"changelog": {
"automaticFromRef": true,
"projectChangelogs": {
"createRelease": "github"
}
}
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"devDependencies": {
"@angular-devkit/core": "~17.3.7",
"@cloudflare/next-on-pages": "^1.12.0",
"@cloudflare/vitest-pool-workers": "^0.4.7",
"@cloudflare/workers-types": "^4.20240512.0",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@eslint/eslintrc": "^2.1.2",
"@eslint/js": "^8.52.0",
"@jscutlery/semver": "^5.2.0",
"@nx/angular": "19.3.2",
"@nx/devkit": "19.3.2",
"@nx/esbuild": "19.3.2",
Expand Down Expand Up @@ -62,7 +62,6 @@
"jest-environment-jsdom": "^29.4.1",
"jest-environment-node": "^29.4.1",
"kill-port": "^2.0.1",
"ngx-deploy-npm": "^7.1.0",
"nx": "19.3.2",
"nx-cloud": "19.0.0",
"prettier": "^2.6.2",
Expand Down
11 changes: 0 additions & 11 deletions packages/e2e-utils/jest.config.ts

This file was deleted.

10 changes: 1 addition & 9 deletions packages/e2e-utils/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,5 @@
"sourceRoot": "packages/e2e-utils/src",
"projectType": "library",
"tags": [],
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/e2e-utils/jest.config.ts"
}
}
}
"targets": {}
}
3 changes: 3 additions & 0 deletions packages/nx-cloudflare-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"sourceRoot": "packages/nx-cloudflare-e2e/src",
"implicitDependencies": ["nx-cloudflare"],
"targets": {
"test": {
"command": "echo 'Use e2e instead'"
},
"e2e": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
Expand Down
29 changes: 9 additions & 20 deletions packages/nx-cloudflare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,45 @@
# Changelog

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [3.0.0](https://github.com/naxodev/oss/compare/v2.2.0...v3.0.0) (2024-05-18)


### ⚠ BREAKING CHANGES

* upgrade to nx 19 (#46)
- upgrade to nx 19 (#46)

### Features

* upgrade to nx 19 ([#46](https://github.com/naxodev/oss/issues/46)) ([da51f24](https://github.com/naxodev/oss/commit/da51f24498aa8762d3bbb35f7726ed1eb0a3193c))
- upgrade to nx 19 ([#46](https://github.com/naxodev/oss/issues/46)) ([da51f24](https://github.com/naxodev/oss/commit/da51f24498aa8762d3bbb35f7726ed1eb0a3193c))

## [2.2.0](https://github.com/naxodev/oss/compare/v2.1.0...v2.2.0) (2024-04-21)


### Features

* update packages ([#44](https://github.com/naxodev/oss/issues/44)) ([bb71b17](https://github.com/naxodev/oss/commit/bb71b1738625b7bccf8bc68e93659b73f91e9828))

- update packages ([#44](https://github.com/naxodev/oss/issues/44)) ([bb71b17](https://github.com/naxodev/oss/commit/bb71b1738625b7bccf8bc68e93659b73f91e9828))

### Bug Fixes

* compatibility warning on deploy ([#43](https://github.com/naxodev/oss/issues/43)) ([4ff171c](https://github.com/naxodev/oss/commit/4ff171c82f5d3edaaa5582894ec410aa10b3bfce))
- compatibility warning on deploy ([#43](https://github.com/naxodev/oss/issues/43)) ([4ff171c](https://github.com/naxodev/oss/commit/4ff171c82f5d3edaaa5582894ec410aa10b3bfce))

## [2.1.0](https://github.com/naxodev/oss/compare/v2.0.1...v2.1.0) (2024-04-12)


### Features

* install vitest using crystal ([#41](https://github.com/naxodev/oss/issues/41)) ([72b6a97](https://github.com/naxodev/oss/commit/72b6a97d904950cccc856edef4de050f93e7a595))
- install vitest using crystal ([#41](https://github.com/naxodev/oss/issues/41)) ([72b6a97](https://github.com/naxodev/oss/commit/72b6a97d904950cccc856edef4de050f93e7a595))

## [2.0.1](https://github.com/naxodev/oss/compare/v2.0.0...v2.0.1) (2024-03-04)


### Bug Fixes

* nx-cloudflare Readme ([72f8e27](https://github.com/naxodev/oss/commit/72f8e2768e8c69f1de734fdef4e9b5f589107694))
- nx-cloudflare Readme ([72f8e27](https://github.com/naxodev/oss/commit/72f8e2768e8c69f1de734fdef4e9b5f589107694))

## [2.0.0](https://github.com/naxodev/oss/compare/v1.0.2...v2.0.0) (2024-03-02)


### ⚠ BREAKING CHANGES

* upgrade to nx 18 (#33)
- upgrade to nx 18 (#33)

### Bug Fixes

* release pipeline ([#34](https://github.com/naxodev/oss/issues/34)) ([50b3d3a](https://github.com/naxodev/oss/commit/50b3d3ad484df16202c44b257ee3fd4a2542c013))

- release pipeline ([#34](https://github.com/naxodev/oss/issues/34)) ([50b3d3a](https://github.com/naxodev/oss/commit/50b3d3ad484df16202c44b257ee3fd4a2542c013))

### Miscellaneous Chores

* upgrade to nx 18 ([#33](https://github.com/naxodev/oss/issues/33)) ([2a3b3ef](https://github.com/naxodev/oss/commit/2a3b3ef1646989aa721aa38337b74aa1f8a5dd32))
- upgrade to nx 18 ([#33](https://github.com/naxodev/oss/issues/33)) ([2a3b3ef](https://github.com/naxodev/oss/commit/2a3b3ef1646989aa721aa38337b74aa1f8a5dd32))
32 changes: 16 additions & 16 deletions packages/nx-cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,22 @@ nx g @naxodev/nx-cloudflare:library my-worker-lib

Available options:

| Option | Type | Default | Description |
| ------------------------ | ------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name | string | \*required | What name would you like to use? |
| directory | string | null | The directory of the new application. |
| projectNameAndRootFormat | as-provided, derived | as-provided | Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`). |
| linter | eslint, none | eslint | The tool to use for running lint checks. |
| unitTestRunner | vitest, none | vitest | Test runner to use for unit tests. |
| tags | string | null | Add tags to the application (used for linting). |
| skipFormat | boolean | false | Skip formatting files. |
| js | boolean | false | Use JavaScript instead of TypeScript |
| strict | boolean | true | Whether to enable tsconfig strict mode or not. |
| publishable | boolean | false | Generate a publishable library. |
| importPath | string | null | The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library. |
| bundler | swc, tsc, rollup, vite, esbuild, none | tsc | Which bundler would you like to use to build the library? Choose 'none' to skip build setup. |
| minimal | boolean | false | Generate a library with a minimal setup. No README.md generated. |
| simpleName | boolean | false | Don't include the directory in the generated file name. |
| Option | Type | Default | Description |
| ------------------------ | ----------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name | string | \*required | What name would you like to use? |
| directory | string | null | The directory of the new application. |
| projectNameAndRootFormat | as-provided, derived | as-provided | Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`). |
| linter | eslint, none | eslint | The tool to use for running lint checks. |
| unitTestRunner | vitest, none | vitest | Test runner to use for unit tests. |
| tags | string | null | Add tags to the application (used for linting). |
| skipFormat | boolean | false | Skip formatting files. |
| js | boolean | false | Use JavaScript instead of TypeScript |
| strict | boolean | true | Whether to enable tsconfig strict mode or not. |
| publishable | boolean | false | Generate a publishable library. |
| importPath | string | null | The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library. |
| bundler | swc, tsc, vite, esbuild, none | tsc | Which bundler would you like to use to build the library? Choose 'none' to skip build setup. |
| minimal | boolean | false | Generate a library with a minimal setup. No README.md generated. |
| simpleName | boolean | false | Don't include the directory in the generated file name. |

### NextJS on Cloudflare

Expand Down
2 changes: 1 addition & 1 deletion packages/nx-cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@naxodev/nx-cloudflare",
"version": "3.0.0",
"version": "3.0.1",
"description": "Nx plugin for Cloudflare",
"homepage": "https://github.com/naxodev/oss/tree/main/packages/nx-cloudflare",
"repository": {
Expand Down
31 changes: 0 additions & 31 deletions packages/nx-cloudflare/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,6 @@
}
]
}
},
"version": {
"dependsOn": ["build"],
"executor": "@jscutlery/semver:version",
"options": {
"preset": "conventional",
"tagPrefix": "v",
"noVerify": true,
"push": true,
"preid": "beta",
"syncVersions": false,
"commitMessageFormat": "release(${projectName}): 🎸 cut release to ${version}",
"postTargets": ["nx-cloudflare:github", "nx-cloudflare:npm-publish"]
}
},
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "${tag}",
"notes": "${notes}"
}
},
"npm-publish": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
}
},
"publish": {
"command": "node tools/scripts/publish.mjs nx-cloudflare {args.ver} {args.tag}",
"dependsOn": ["build"]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name = "<%=name %>"
compatibility_date = "2024-04-19"
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
main = "src/index.<%=extension %>"
<%-accountId %>

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { SELF } from "cloudflare:test";
<%-vitestImports %>
import "../src";

// an integration test using SELF
it("sends request (integration style)", async () => {
const response = await SELF.fetch("http://example.com");
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
});
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import { unstable_dev } from 'wrangler';
import type { UnstableDevWorker } from 'wrangler';
import { env, createExecutionContext, waitOnExecutionContext, } from "cloudflare:test";
import { worker } from './src'
<%-vitestImports %>

describe('Worker', () => {
let worker: UnstableDevWorker;

beforeAll(async () => {
worker = await unstable_dev('src/index.ts', {
experimental: { disableExperimentalWarning: true },
});
});

afterAll(async () => {
await worker.stop();
});

it('should return Hello World', async () => {
const resp = await worker.fetch();
if (resp) {
const text = await resp.text();
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
}
const request = new Request("http://example.com/");
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import { SELF } from "cloudflare:test";
<%-vitestImports %>
import "../src";

// an integration test using SELF
it("sends request (integration style)", async () => {
const response = await SELF.fetch("http://example.com");
expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
});
Loading
Loading