Skip to content
Merged
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
5 changes: 1 addition & 4 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,4 @@ jobs:
To ensure this release is ready to be merged:
- [ ] Review updated CHANGELOG(s)

After merging this PR, please do the following:
- [ ] Run the `tag-release` CI workflow (specifying the commit hash of this PR once fast-forwarded onto `main`)
- [ ] Run the `release` CI workflow (specifying the released tag)
- [ ] Make releases to downstream repositories (e.g. NPM) for the released artifacts as necessary
After this PR is merged tagging, artifacts and releasing should run automatically.
91 changes: 91 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: lint

on:
merge_group:
pull_request:
branches:
- main

permissions:
contents: none

jobs:
conventional-commits:
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3

- name: Cache npm install
id: cache-node-modules
uses: actions/cache@v4
with:
key: node-modules-dev-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
path: |
node_modules
- name: Install debug NPM packages
run: |
npm install -D

- name: Validate PR commits with commitlint
id: cc
env:
COMMITLINT_START_REF: ${{ github.event.pull_request.base.sha || 'HEAD^' }}
COMMITLINT_END_REF: ${{ github.event.pull_request.head.sha || 'HEAD' }}
run: |
node scripts/lint-cc.mjs

- name: Create CC fix comment
if: ${{ steps.cc.outputs.fail == 'true' }}
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
with:
number: ${{ github.event.pull_request.number }}
header: tip-cc
recreate: true
hide_and_recreate: true
skip_unchanged: true
message: | # markdown
### :warning: It looks like your commit is not formatted in line with Conventional Commits

This repository uses [Conventional Commits][cc] to enable automation and ensure consistent commit messages across the project.

### ❌ Errors

| Error Name | Error Message | Commit Message |
|------------|---------------|----------------|
${{ steps.cc.outputs.error-rows-md-table }}

### ⚠ Warnings

| Warning Name | Warning Message | Commit Message |
|------------|---------------|----------------|
${{ steps.cc.outputs.warning-rows-md-table }}

### How to fix this issue

Please `git amend` (including a `git rebase` if necessary) your commits to follow the [Conventional Commits][cc] format.

> [!NOTE]
> If you don't feel comfortable doing this, don't worry—a project maintainer can help correct this for you, before merging.
>
> Ensure that maintainers are allowed to modify your pull requests.

[cc]: https://www.conventionalcommits.org/en/v1.0.0

- name: Hide PR Comment
if: ${{ steps.cc.outputs.success == 'true' }}
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
with:
number: ${{ github.event.pull_request.number }}
header: tip-cc
hide: true
hide_classify: "RESOLVED"
append: true
skip_unchanged: true
only_update: true
message: "This PR is now formatted in line with Conventional Commits"
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defaults:
jobs:
build:
name: Jco Build
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
Expand Down
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

## [jco-v1.11.0] - 2025-04-28

### 🚀 Features
Expand All @@ -13,4 +11,4 @@ All notable changes to this project will be documented in this file.
## New Contributors
* @tanishiking made their first contribution in [#631](https://github.com/bytecodealliance/jco/pull/631)
* @marosset made their first contribution in [#609](https://github.com/bytecodealliance/jco/pull/609)
* @MendyBerger made their first contribution in [#591](https://github.com/bytecodealliance/jco/pull/591)
* @MendyBerger made their first contribution in [#591](https://github.com/bytecodealliance/jco/pull/591)
3 changes: 1 addition & 2 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
[changelog]
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
## [{{ version | trim_start_matches(pat="jco-v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
Expand Down
28 changes: 28 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const config = {
extends: ["@commitlint/config-conventional"],
parserPreset: "conventional-changelog-conventionalcommits",
rules: {
"type-enum": [
2,
"always",
[
"build",
"debug",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
],
],
"scope-enum": [1, "always", ["jco", "bindgen", "p2-shim"]],
"scope-case": [2, "always", "kebab-case"],
},
};

export default config;
1 change: 0 additions & 1 deletion crates/js-component-bindgen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

## [js-component-bindgen-v1.11.0] - 2025-04-28

Expand Down
3 changes: 1 addition & 2 deletions crates/js-component-bindgen/cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
[changelog]
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
## [{{ version | trim_start_matches(pat="js-component-bindgen-v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
"terser": "^5"
},
"devDependencies": {
"@commitlint/config-conventional": "^19.8.1",
"@types/node": "^20.14.12",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"commitlint": "^19.8.1",
"conventional-changelog-conventionalcommits": "^8.0.0",
"eslint": "^9.9.0",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-prettier": "^5.2.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/preview2-shim/cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
[changelog]
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
## [{{ version | trim_start_matches(pat="preview2-shim-v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
Expand Down
154 changes: 154 additions & 0 deletions scripts/lint-cc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import { env } from "node:process";
import { appendFile } from "node:fs/promises";

import load from "@commitlint/load";
import lint from "@commitlint/lint";
import read from "@commitlint/read";

import { default as config } from "../commitlint.config.mjs";

/**
* Entrypoint that performs conventional commit checks on this repository
*/
async function main() {
// Load config for the relevant project
const opts = await load(config);

// Figure out the start/end of the commits to check
const start = env.COMMITLINT_START_REF;
const end = env.COMMITLINT_END_REF;
if (!start || !end) {
throw new Error(`Missing/invalid start/end (${start}/${end})`);
}

// Get the commit messages
const commits = await read({ to: end, from: start });

// Lint commit messages
let invalidCommits = [];
for (const msg of commits) {
console.error(`checking commit msg\n---\n${msg}\n---\n`);
const title = msg.split("\n")[0];
const { valid, errors, warnings } = await lint(
title,
opts.rules,
opts.parserPreset ? { parserOpts: opts.parserPreset.parserOpts } : {},
);
if (!valid) {
invalidCommits.push({
title,
errors,
warnings,
});
}
}

await logJobOutput({
invalidCommits,
});
}

/** Print job output */
async function logJobOutput(output) {
// If we're in CI, then use GITHUB_STEP_SUMMARY & GITHUB_OUTPUT
// to produce useful output
if (env.CI) {
if (!env.GITHUB_STEP_SUMMARY) {
throw new Error("Missing/invalid GITHUB_STEP_SUMMARY ENV variable in CI");
}
if (!env.GITHUB_OUTPUT) {
throw new Error("Missing/invalid GITHUB_OUTPUT ENV variable in CI");
}

// Print all errors, if present
const failed = output.invalidCommits.length > 0;
if (failed) {
output.invalidCommits.forEach((c) => {
c.errors.forEach((e) => {
console.log(`::error::[${e.name}]: ${e.message}`);
});
});
}

await appendFile(env.GITHUB_STEP_SUMMARY, genCIStepSummary(output));
await appendFile(env.GITHUB_OUTPUT, `success=${!failed}\n`);
await appendFile(env.GITHUB_OUTPUT, `fail=${failed}\n`);
await appendFile(
env.GITHUB_OUTPUT,
`invalid-commit-count=${output.invalidCommits.length}\n`,
);

const errorRowsMd = [];
output.invalidCommits.forEach((c) => {
c.errors.forEach((e) => {
errorRowsMd.push("|" + [e.name, e.message, c.title].join("|") + "|");
});
});
await appendFile(
env.GITHUB_OUTPUT,
`error-rows-md-table<<EOF\n${errorRowsMd.join("\n")}\nEOF\n`,
);

const warningRowsMd = [];
output.invalidCommits.forEach((c) => {
c.warnings.forEach((w) => {
warningRowsMd.push("|" + [w.name, w.message, c.title].join("|") + "|");
});
});
await appendFile(
env.GITHUB_OUTPUT,
`warning-rows-md-table<<EOF\n${warningRowsMd.join("\n")}\nEOF\n`,
);

return;
}

// If we're not in CI, print output to STDERR
console.error(`error? [${output.hasError}]`);

// Print all warnings
output.invalidCommits.forEach((c) => {
c.warnings.forEach((w) => {
console.error(`warning: [${w.name}]: ${w.message}`);
});
});

// Print all errors
output.invalidCommits.forEach((c) => {
c.errors.forEach((e) => {
console.error(`error: [${e.name}]: ${e.message}`);
});
});

// Pretty print information to STDOUT
console.log(JSON.stringify(output, 2, null));
return;
}

/** Generate summary for CI (GitHub) step */
function genCIStepSummary(output) {
let summary = "### Conventional Commits: ";

summary += output.hasError ? "❌" : "✅";
summary += "\n";

if (output.invalidCommits.length > 0) {
summary += "## Invalid Commits";
output.invalidCommits.forEach((c) => {
c.errors.forEach((e) => {
summary += `error: [${e.name}]: ${e.message}\n`;
});
});

summary += "## Warnings";
output.invalidCommits.forEach((c) => {
c.warnings.forEach((w) => {
summary += `warning: [${w.name}]: ${w.message}\n`;
});
});
}

return summary;
}

await main();
2 changes: 1 addition & 1 deletion src/jco.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ program
.name('jco')
.description(c`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
.usage('<command> [options]')
.version('1.10.2');
.version('1.11.1');

function myParseInt(value) {
return parseInt(value, 10);
Expand Down
Loading