Skip to content

Commit d7028df

Browse files
committed
build!: ✨ rework build and ci
Replace CI Workflows, updated deps, update readme and repo links WASM no longer inlined (as that also proved unreliable and now platform-specific importing is required)
1 parent a7bdcfc commit d7028df

File tree

19 files changed

+538
-185
lines changed

19 files changed

+538
-185
lines changed

.github/CONTRIBUTING.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributing to maxminddb-deno
1+
# Contributing to maxminddb-wasm
22

33
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
44

@@ -32,25 +32,25 @@ This project and everyone participating in it is governed by [the repository's c
3232

3333
### Reporting bugs
3434

35-
This section guides you through submitting a bug report for maxminddb-deno. Following these guidelines helps maintainers and the community understand your report 📝, reproduce the behavior 💻, and find related reports 🔎.
35+
This section guides you through submitting a bug report for maxminddb-wasm. Following these guidelines helps maintainers and the community understand your report 📝, reproduce the behavior 💻, and find related reports 🔎.
3636

37-
Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](https://github.com/josh-hemphill/maxminddb-deno/.github/.github/ISSUE_TEMPLATE/bug_report.md), the information it asks for helps us resolve issues faster.
37+
Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](https://github.com/josh-hemphill/maxminddb-wasm/.github/.github/ISSUE_TEMPLATE/bug_report.md), the information it asks for helps us resolve issues faster.
3838

3939
#### Before Submitting A Bug Report
4040

41-
- **Determine** the error or issue happens inside maxminddb-deno code, and is not an expected error in response to user input.
42-
- **Perform** a [cursory search](https://github.com/issues?utf8=✓&q=is%3Aissue+repo%3Ajosh-hemphill/maxminddb-deno+label%3Abug) to see if the problem has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one.
41+
- **Determine** the error or issue happens inside maxminddb-wasm code, and is not an expected error in response to user input.
42+
- **Perform** a [cursory search](https://github.com/issues?utf8=✓&q=is%3Aissue+repo%3Ajosh-hemphill/maxminddb-wasm+label%3Abug) to see if the problem has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one.
4343

4444
#### How Do I Submit A (Good) Bug Report?
4545

4646
Explain the problem and include additional details to help maintainers reproduce the problem:
4747

4848
- **Use a clear and descriptive title** for the issue to identify the problem.
49-
- **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how you invoked maxminddb-deno, e.g. which function exactly you used, or how you imported it otherwise. When listing steps, **don't just say what you did, but explain how you did it**. For example, if you used an internal function, don't just say you used it, provide what data you passed it, and if/how it was passed back into other maxminddb-deno functions.
49+
- **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how you invoked maxminddb-wasm, e.g. which function exactly you used, or how you imported it otherwise. When listing steps, **don't just say what you did, but explain how you did it**. For example, if you used an internal function, don't just say you used it, provide what data you passed it, and if/how it was passed back into other maxminddb-wasm functions.
5050
- **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
5151
- **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
5252
- **Explain which behavior you expected to see instead and why.**
53-
- **If you're reporting that maxminddb-deno errored out**, provide the whole stack trace in the issue in a [code block](https://help.github.com/articles/markdown-basics/#multiple-lines), a [file attachment](https://help.github.com/articles/file-attachments-on-issues-and-pull-requests/), or put it in a [gist](https://gist.github.com/) and provide link to that gist.
53+
- **If you're reporting that maxminddb-wasm errored out**, provide the whole stack trace in the issue in a [code block](https://help.github.com/articles/markdown-basics/#multiple-lines), a [file attachment](https://help.github.com/articles/file-attachments-on-issues-and-pull-requests/), or put it in a [gist](https://gist.github.com/) and provide link to that gist.
5454
- **If the problem is related to performance or memory**, include a benchmark link with your report.
5555
- **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below.
5656

@@ -69,13 +69,13 @@ Include details about your configuration and environment:
6969

7070
### Suggesting Enhancements
7171

72-
This section guides you through submitting an enhancement suggestion for maxminddb-deno, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:.
72+
This section guides you through submitting an enhancement suggestion for maxminddb-wasm, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:.
7373

74-
Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in [the template](https://github.com/josh-hemphill/maxminddb-deno/.github/blob/master/.github/ISSUE_TEMPLATE/feature_request.md), including the steps that you imagine you would take if the feature you're requesting existed.
74+
Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in [the template](https://github.com/josh-hemphill/maxminddb-wasm/.github/blob/master/.github/ISSUE_TEMPLATE/feature_request.md), including the steps that you imagine you would take if the feature you're requesting existed.
7575

7676
#### Before Submitting An Enhancement Suggestion
7777

78-
- **Perform** a [cursory search](https://github.com/issues?utf8=✓&q=is%3Aissue+repo%3Ajosh-hemphill/maxminddb-deno+label%3Afeature) to see if the problem has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one.
78+
- **Perform** a [cursory search](https://github.com/issues?utf8=✓&q=is%3Aissue+repo%3Ajosh-hemphill/maxminddb-wasm+label%3Afeature) to see if the problem has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one.
7979

8080
#### How Do I Submit A (Good) Enhancement Suggestion?
8181

@@ -92,7 +92,7 @@ Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com
9292

9393
### Your First Code Contribution
9494

95-
Unsure where to begin contributing to maxminddb-deno? You can start by looking through these `beginner` and `help-wanted` issues:
95+
Unsure where to begin contributing to maxminddb-wasm? You can start by looking through these `beginner` and `help-wanted` issues:
9696

9797
- [Beginner issues][beginner] - issues which should only require a few lines of code, and a test or two.
9898
- [Help wanted issues][help-wanted] - issues which should be a bit more involved than `beginner` issues.
@@ -102,16 +102,16 @@ While not perfect, number of comments is a reasonable proxy for impact a given c
102102

103103
#### Local development
104104

105-
For instructions on how to setup and run development, see the following [Development Guide](https://github.com/josh-hemphill/maxminddb-deno/docs/development.md)
105+
For instructions on how to setup and run development, see the following [Development Guide](https://github.com/josh-hemphill/maxminddb-wasm/docs/development.md)
106106

107107
### Pull Requests
108108

109109
The process described here has several goals:
110110

111-
- Maintain maxminddb-deno's quality
111+
- Maintain maxminddb-wasm's quality
112112
- Fix problems that are important to users
113-
- Engage the community in working toward the best possible maxminddb-deno
114-
- Enable a sustainable system for maxminddb-deno's maintainers to review contributions
113+
- Engage the community in working toward the best possible maxminddb-wasm
114+
- Enable a sustainable system for maxminddb-wasm's maintainers to review contributions
115115

116116
Please follow these steps to have your contribution considered by the maintainers:
117117

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ assignees: 'josh-hemphill'
88

99
<!--
1010
11-
Have you read maxmind-deno's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/josh-hemphill/maxmind-deno/.github/CODE_OF_CONDUCT.md
11+
Have you read maxminddb-wasm's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/josh-hemphill/maxminddb-wasm/.github/CODE_OF_CONDUCT.md
1212
1313
-->
1414

1515
### Prerequisites
1616

17-
* [ ] Reproduced the problem in a sandbox or repo: <https://codepen.io>
18-
* [ ] Checked that your issue isn't already filed: <https://github.com/issues?utf8=✓&q=is%3Aissue+repo%3Ajosh-hemphill/maxmind-deno>
17+
* [ ] Reproduced the problem in a sandbox or repo
18+
* [ ] Checked that your issue isn't already filed: <https://github.com/issues?utf8=✓&q=is%3Aissue+repo%3Ajosh-hemphill/maxminddb-wasm>
1919

2020
### Description
2121

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: "\U0001F680 Feature Request"
3-
about: I have an idea for maxminddb-deno
3+
about: I have an idea for maxminddb-wasm
44
title: '[Enhance]: %s'
55
labels: [feature, feature_request]
66
assignees: 'josh-hemphill'
@@ -9,7 +9,7 @@ assignees: 'josh-hemphill'
99

1010
<!--
1111
12-
Have you read maxminddb-deno's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/josh-hemphill/maxminddb-deno/.github/CODE_OF_CONDUCT.md
12+
Have you read maxminddb-wasm's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/josh-hemphill/maxminddb-wasm/.github/CODE_OF_CONDUCT.md
1313
1414
-->
1515

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Setup and cache
2+
description: Setup for node, pnpm and cache for browser testing binaries
3+
inputs:
4+
node-version:
5+
required: false
6+
description: Node version for setup-node
7+
default: 20.x
8+
9+
runs:
10+
using: composite
11+
12+
steps:
13+
- name: Install pnpm
14+
uses: pnpm/action-setup@v4
15+
16+
- name: Set node version to ${{ inputs.node-version }}
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ inputs.node-version }}
20+
21+
- name: Resolve package versions
22+
id: resolve-package-versions
23+
shell: bash
24+
run: >
25+
echo "$(
26+
node -e "
27+
const fs = require('fs');
28+
const lockfile = fs.readFileSync('./pnpm-lock.yaml', 'utf8');
29+
const pattern = (name) => new RegExp(name + ':\\\s+specifier: [\\\s\\\w\\\.^]+version: (\\\d+\\\.\\\d+\\\.\\\d+)');
30+
const playwrightVersion = lockfile.match(pattern('playwright'))[1];
31+
console.log('PLAYWRIGHT_VERSION=' + playwrightVersion);
32+
"
33+
)" >> $GITHUB_OUTPUT
34+
35+
- name: Print versions
36+
shell: bash
37+
run: echo "${{ toJson(steps.resolve-package-versions.outputs) }}"
38+
39+
- name: Check resolved package versions
40+
shell: bash
41+
if: |
42+
contains(fromJSON('[null, "", "undefined"]'), steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION)
43+
run: echo "Failed to resolve package versions. See log above." && exit 1
44+
45+
- name: Cache Playwright v${{ steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION }}
46+
uses: actions/cache@v4
47+
id: playwright-cache
48+
with:
49+
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
50+
key: ${{ runner.os }}-playwright-${{ steps.resolve-package-versions.outputs.PLAYWRIGHT_VERSION }}
51+
restore-keys: |
52+
${{ runner.os }}-playwright-

.github/stale.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- dev-next
8+
- next
9+
- beta
10+
- alpha
11+
- "*.x"
12+
paths:
13+
- "**.ts"
14+
- ".github/workflows/**.yml"
15+
- ".github/actions/**.yml"
16+
- "src/**"
17+
- "test/**"
18+
- "*.json"
19+
pull_request:
20+
paths:
21+
- "**.ts"
22+
- ".github/workflows/**.yml"
23+
- ".github/actions/**.yml"
24+
- "src/**"
25+
- "test/**"
26+
- "*.json"
27+
types:
28+
- opened
29+
- synchronize
30+
workflow_dispatch:
31+
workflow_call:
32+
inputs:
33+
release:
34+
type: boolean
35+
default: false
36+
37+
concurrency:
38+
group: ci-${{ github.event.pull_request.number || github.ref }}
39+
cancel-in-progress: true
40+
41+
env:
42+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
43+
44+
jobs:
45+
build:
46+
runs-on: ubuntu-latest
47+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v3
51+
52+
- name: Setup Rust
53+
uses: actions-rs/toolchain@v1
54+
with:
55+
toolchain: stable
56+
target: wasm32-unknown-unknown
57+
58+
- name: Setup and cache dependencies
59+
uses: ./.github/actions/setup-and-cache
60+
61+
- name: Install dependencies
62+
run: pnpm install --frozen-lockfile --no-optional
63+
64+
- name: Build
65+
run: pnpm build
66+
67+
- name: Upload build artifacts
68+
if: inputs.release == true
69+
uses: actions/upload-artifact@v3
70+
with:
71+
name: build-artifacts
72+
path: |
73+
browser/
74+
bundler/
75+
node/
76+
node-module/
77+
package.json
78+
README.md
79+
LICENSE
80+
jsr.json
81+
retention-days: 1
82+
83+
- uses: browser-actions/setup-chrome@v1
84+
- name: Install test dependencies
85+
run: pnpm install --frozen-lockfile
86+
87+
- name: Test
88+
continue-on-error: true
89+
run: pnpm test-ci
90+
91+
- name: Generate test badges
92+
run: >
93+
node -e "
94+
const fs = require('zx/globals');
95+
const testSummary = fs.readJsonSync('./pnpm-exec-summary.json');
96+
const degraded = [];
97+
let comment = '### Test Results\n\n';
98+
comment += '| Test Suite | Status |\n';
99+
comment += '|------------|---------|\n';
100+
Object.entries(testSummary.executionStatus).map(([name, status]) => ({
101+
label: name.split(path.sep).pop(),
102+
message: status.status,
103+
color: status.status === 'passed' ? 'green' : 'red'
104+
})).forEach((spec) => {
105+
const svg = badge(spec);
106+
const statPath = `.github/badges/test-stats-${spec.label}.json`;
107+
const oldStat = fs.readJsonSync(statPath, { throws: false });
108+
if (oldStat.message === 'passed' && spec.message !== 'passed') {
109+
degraded.push(spec.label);
110+
}
111+
fs.ensureFileSync(statPath, JSON.stringify(testSummary, null, 2));
112+
fs.ensureFileSync(`.github/badges/test-${spec.label}.svg`, svg);
113+
const statusEmoji = status.status === 'passed' ? '✅' : '❌';
114+
comment += `| ${suite} | ${statusEmoji} ${status.status} |\n`;
115+
});
116+
if (degraded.length > 0) {
117+
throw new Error(`The following tests have degraded: ${degraded.join(', ')}`);
118+
}
119+
fs.writeFileSync('test-results.txt', comment);
120+
"
121+
122+
- name: Post Test Results Comment
123+
if: github.event_name == 'pull_request'
124+
uses: actions/github-script@v6
125+
with:
126+
script: |
127+
const fs = require('fs');
128+
const comment = fs.readFileSync('test-results.txt', 'utf8');
129+
const { owner, repo } = context.repo;
130+
const issue_number = context.issue.number;
131+
132+
await github.rest.issues.createComment({
133+
owner,
134+
repo,
135+
issue_number,
136+
body: comment
137+
});
138+
139+
- name: Commit test badges
140+
if: github.event.pull_request.number == null || inputs.release == false
141+
uses: stefanzweifel/git-auto-commit-action@v5
142+
with:
143+
commit_message: "📝 docs: update test badges [skip ci]"
144+
file_pattern: "*.svg"

0 commit comments

Comments
 (0)