Skip to content

Commit

Permalink
Improve CI and use pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
w1am committed Dec 19, 2024
1 parent c7e8545 commit cdf2703
Show file tree
Hide file tree
Showing 18 changed files with 5,401 additions and 202 deletions.
60 changes: 60 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Bug Report
description: Create a bug report to help us improve
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: description
attributes:
label: Bug Description
description: A clear and concise description of what the bug is
placeholder: Tell us what you see!
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: To Reproduce
description: Steps to reproduce the behavior
placeholder: |
1. Start the KurrentDB server
2. Connect the client to the server
3. Create a new stream
4. Append an event to the stream
5. Read the event from the stream
6. Observe the issue
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen
validations:
required: true
- type: markdown
attributes:
value: '## Environment'
- type: input
id: db
attributes:
label: KurrentDB Version
placeholder: ex. 24.10.0
validations:
required: true
- type: input
id: client
attributes:
label: Client Version
placeholder: ex. 1.0.0
validations:
required: true
- type: input
id: nodejs-version
attributes:
label: Node.js Version
placeholder: ex. 18.16.0
validations:
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Feature request
url: https://discuss.eventstore.com/
about: Suggest an idea for this project
- name: Question / Problem
url: https://discuss.eventstore.com/
about: Questions and problems with n8n
34 changes: 34 additions & 0 deletions .github/scripts/bump_versions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {promisify} from 'util';
import assert from 'assert';
import {resolve} from 'path';
import semver from 'semver';
import {exec as execCallback} from 'child_process';
import {writeFile, readFile} from 'fs/promises';

const exec = promisify(execCallback);

async function updatePackageVersion(packagePath, currentVersion, releaseType) {
const packageFile = resolve(packagePath, 'package.json');
const packageJson = JSON.parse(await readFile(packageFile, 'utf-8'));

packageJson.version = semver.inc(currentVersion, releaseType);

await writeFile(packageFile, JSON.stringify(packageJson, null, 2) + '\n');
}

async function main() {
const releaseType = process.env.RELEASE_TYPE;
assert.match(releaseType, /^(patch|minor|major)$/, 'Invalid RELEASE_TYPE');

const packages = JSON.parse((await exec('pnpm ls -r --only-projects --json')).stdout);

for (let {name, path, version, private: isPrivate} of packages) {
if (isPrivate && name !== 'kurrent-node-client-repository') continue;
await updatePackageVersion(path, version, releaseType);
}
}

main().catch(error => {
console.error('Error updating package versions:', error);
process.exit(1);
});
31 changes: 25 additions & 6 deletions .github/workflows/build_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v4
with:
version: 9.15.0

- name: Install
run: npm install
run: pnpm install

- name: Linting
run: npm run lint
run: pnpm run lint

- name: Build on Ubuntu
run: npm run build
run: pnpm run build

- name: All generated code is commited
run: |
git update-index --refresh
Expand All @@ -30,17 +38,28 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 9.15.0

- uses: actions/setup-node@v4
with:
node-version-file: .github/files/.nvmrc

- name: NodeJS version
run: node -v

- name: PNPM version
run: pnpm --version

- name: Install
run: npm install
run: pnpm install

- name: Build
run: npm run build
run: pnpm run build
62 changes: 62 additions & 0 deletions .github/workflows/release_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Release: Create Pull Request'

on:
workflow_dispatch:
inputs:
base-branch:
description: 'The branch, tag, or commit to create this release PR from.'
required: true
default: 'master'

release-type:
description: 'A SemVer release type.'
required: true
type: choice
default: 'minor'
options:
- patch
- minor
- major

jobs:
create-release-pr:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

timeout-minutes: 5

steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ github.event.inputs.base-branch }}

- uses: pnpm/action-setup@v4
with:
version: 9.15.0

- run: npm install --prefix=.github/scripts --no-package-lock

- name: Bump package versions
run: |
echo "NEXT_RELEASE=$(node .github/scripts/bump_versions.mjs)" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}

- name: Push the base branch
run: |
git push -f origin refs/remotes/origin/${{ github.event.inputs.base-branch }}:refs/heads/release/${{ env.NEXT_RELEASE }}
- name: Push the release branch, and Create the PR
uses: peter-evans/create-pull-request@v6
with:
base: 'release/${{ env.NEXT_RELEASE }}'
branch: 'release-pr/${{ env.NEXT_RELEASE }}'
commit-message: 'Release ${{ env.NEXT_RELEASE }}'
delete-branch: true
labels: release,release:${{ github.event.inputs.release-type }}
title: 'Release ${{ env.NEXT_RELEASE }}'
47 changes: 47 additions & 0 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Release: Publish'

on:
pull_request:
types:
- closed
branches:
- 'release/*'

jobs:
publish-to-npm:
name: Publish to NPM
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
timeout-minutes: 10
permissions:
id-token: write
outputs:
release: ${{ steps.set-release.outputs.release }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- uses: pnpm/[email protected]
with:
version: 9.15.0

- run: pnpm install

- name: Build
run: pnpm run build

- name: Cache build artifacts
uses: actions/cache/[email protected]
with:
path: ./packages/**/dist
key: ${{ github.sha }}-release:build

- name: Dry-run publishing
run: pnpm publish -r --no-git-checks --dry-run

- name: Publish to NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
pnpm publish -r --publish-branch ${{github.event.pull_request.base.ref}} --access public --no-git-checks
20 changes: 16 additions & 4 deletions .github/workflows/test_ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,38 @@ jobs:
sudo apt-get update
sudo apt-get install tailscale
sudo tailscale up --authkey ${{ secrets.TAILSCALE_AUTH }} --hostname "node-client-ci-${{ env.KURRENT_VERSION }}-$(date +'%Y-%m-%d-%H-%M-%S')" --advertise-tags=tag:ci --accept-routes
- uses: pnpm/action-setup@v4
with:
version: 9.15.0

- uses: actions/setup-node@v4
with:
node-version-file: .github/files/.nvmrc
cache: 'pnpm'

- name: NodeJS version
run: node -v

- name: Login to Cloudsmith
uses: docker/login-action@v3
with:
registry: docker.eventstore.com
username: ${{ secrets.CLOUDSMITH_CICD_USER }}
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }}

- name: Install
run: npm install
- name: Build
run: npm run build
run: pnpm install

- name: Build
run: pnpm run build

- name: Run Tests
run: npm run test ${{ matrix.group.path }} --ci --run-in-band --forceExit
run: pnpm run test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
KURRENT_IMAGE: eventstore-ee:${{ env.KURRENT_VERSION }}
EVENTSTORE_CLOUD_ID: ${{ secrets.EVENTSTORE_CLOUD_ID }}

- name: Disconnect from tailscale
if: ${{ always() && matrix.group.tailscale && env.SECRETS_AVAILABLE == 'true' }}
run: sudo tailscale down
17 changes: 14 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,31 @@ jobs:
sudo apt-get update
sudo apt-get install tailscale
sudo tailscale up --authkey ${{ secrets.tailscale_auth }} --hostname "node-client-ci-${{ inputs.version }}-$(date +'%Y-%m-%d-%H-%M-%S')" --advertise-tags=tag:ci --accept-routes
- uses: pnpm/action-setup@v4
with:
version: 9.15.0

- uses: actions/setup-node@v4
with:
node-version-file: .github/files/.nvmrc
cache: 'pnpm'

- name: NodeJS version
run: node -v

- name: Install
run: npm install
run: pnpm install

- name: Build
run: npm run build
run: pnpm run build

- name: Run Tests
run: npm run test ${{ matrix.group.path }} --ci --run-in-band --forceExit
run: pnpm run test ${{ matrix.group.path }} --ci --run-in-band --forceExit
env:
KURRENT_IMAGE: eventstore-ce:${{ inputs.version }}
EVENTSTORE_CLOUD_ID: ${{ secrets.eventstore_cloud_id }}

- name: Disconnect from tailscale
if: ${{ always() && matrix.group.tailscale && env.SECRETS_AVAILABLE == 'true' }}
run: sudo tailscale down
Loading

0 comments on commit cdf2703

Please sign in to comment.