Skip to content

Commit 754527d

Browse files
committed
Release to NPM via GitHub actions
Minor fixes
1 parent 83e5164 commit 754527d

File tree

10 files changed

+156
-20
lines changed

10 files changed

+156
-20
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "npm"
8+
versioning-strategy: "increase"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/automerge.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Automerge dependabot PRs
2+
on:
3+
workflow_run:
4+
workflows:
5+
- CI
6+
types:
7+
- completed
8+
9+
jobs:
10+
Automerge:
11+
runs-on: ubuntu-latest
12+
if: |
13+
github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion == 'success'
15+
permissions:
16+
pull-requests: write
17+
contents: write
18+
steps:
19+
- name: 'Merge PR'
20+
uses: actions/github-script@v7
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
script: |
24+
const pr = await github.rest.pulls.get({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
pull_number: context.payload.workflow_run.pull_requests[0].number,
28+
});
29+
if (pr.data.user.login !== 'dependabot[bot]') {
30+
console.log('Not Merged 🚫');
31+
console.log(`User '${pr.data.user.login}' does not equal 'dependabot[bot]'`);
32+
} else {
33+
await github.rest.pulls.merge({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
pull_number: context.payload.workflow_run.pull_requests[0].number,
37+
});
38+
console.log('Merged 🎉');
39+
}
40+

.github/workflows/main.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
13+
Test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v4
18+
- name: Install Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '*'
22+
check-latest: true
23+
- name: Install Dependencies
24+
run: yarn
25+
- name: Run Tests 👩🏽‍💻
26+
run: yarn test
27+
28+
Lint:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout Code
32+
uses: actions/checkout@v4
33+
- name: Install Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 'lts/*'
37+
- name: Install Dependencies
38+
run: yarn
39+
- name: Lint ✨
40+
run: yarn lint
41+
42+
Build:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout Code
46+
uses: actions/checkout@v4
47+
- name: Install Node
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: 'lts/*'
51+
- name: Install Dependencies
52+
run: yarn
53+
- name: Build 🗜️
54+
run: yarn build
55+
56+
############ Requires NPM_TOKEN in secrets ############
57+
Release:
58+
needs: [Test, Lint, Build]
59+
if: |
60+
github.ref == 'refs/heads/main' &&
61+
github.event.repository.fork == false
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout Code
65+
uses: actions/checkout@v4
66+
- name: Install Node
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: 'lts/*'
70+
- name: Install Dependencies
71+
run: yarn
72+
- name: Build 🗜️
73+
run: yarn build
74+
- name: Release 🎉
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
run: npx semantic-release

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"name": "@letsflow/testing",
3-
"version": "0.0.0",
3+
"version": "1.0.0",
44
"description": "Test suite for LetsFlow",
55
"author": "Arnold Daniels <[email protected]>",
66
"license": "MIT",
77
"publishConfig": {
88
"access": "public"
99
},
10+
"main": "lib/index.js",
11+
"types": "lib/index.d.ts",
1012
"dependencies": {
1113
"@cucumber/cucumber": "^11.2.0",
1214
"@letsflow/core": "^1.5.0",
@@ -28,11 +30,10 @@
2830
},
2931
"files": [
3032
"lib",
31-
"src",
3233
"cucumber.example.yaml"
3334
],
3435
"scripts": {
35-
"clean": "rm -rf ./lib ./dist",
36+
"clean": "rm -rf ./lib",
3637
"build": "tsc --project tsconfig.build.json",
3738
"test": "cucumber-js",
3839
"lint": "eslint \"{src,test}/**/*.ts\" --fix"

src/assert-current.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ function assertStateVar(property: string, processName: string, expectedRaw: any)
1616

1717
expect(actualValue).to.eq(expected, `The ${property} of the current state does not have the expected value`);
1818
}
19-
Then('the state {property} of the {string} process has {string} is {string}', assertStateVar);
20-
Then('the state {property} is {string}', (property, expected) => assertStateVar(property, 'main', expected));
21-
Then('the state {property} of the {string} process is:', (property, process, expected) => assertStateVar(property, process, parseData(expected)));
22-
Then('the state {property} is:', (property, expected) => assertStateVar(property, 'main', parseData(expected)));
19+
Then('the state {property} of the {string} process has {string} is/are {string}', assertStateVar);
20+
Then('the state {property} is/are {string}', (property, expected) => assertStateVar(property, 'main', expected));
21+
Then('the state {property} of the {string} process is:/are:', (property, process, expected) => assertStateVar(property, process, parseData(expected)));
22+
Then('the state {property} is:/are:', (property, expected) => assertStateVar(property, 'main', parseData(expected)));
2323

2424
function assertInstructions(actorKey: string, processName: string, expectedRaw: string) {
2525
const process = world.getProcess(processName);
@@ -32,7 +32,7 @@ function assertInstructions(actorKey: string, processName: string, expectedRaw:
3232

3333
expect(instructions.trim()).to.eq(expected.trim(), `Actor '${actorKey}' does not have the expected instructions`);
3434
}
35-
Then('actor {string} in the {string} process has instructions {string}', assertInstructions);
36-
Then('actor {string} has instructions {string}', (actorKey, expected) => assertInstructions(actorKey, 'main', expected));
37-
Then('actor {string} in the {string} process has instructions:', assertInstructions);
38-
Then('actor {string} has instructions:', (actorKey, expected) => assertInstructions(actorKey, 'main', expected));
35+
Then('actor {string} in the {string} process has (the )instruction(s) {string}', assertInstructions);
36+
Then('actor {string} has (the )instruction(s) {string}', (actorKey, expected) => assertInstructions(actorKey, 'main', expected));
37+
Then('actor {string} in the {string} process has (the )instruction(s):', assertInstructions);
38+
Then('actor {string} has (the )instruction(s):', (actorKey, expected) => assertInstructions(actorKey, 'main', expected));

src/assert-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function nothingIsSkipped(processName: string) {
4343

4444
expect(skippedEvents).to.have.length(0, 'Some events were skipped');
4545
}
46-
Then('nothing is skipped of the {string} process', nothingIsSkipped);
46+
Then('nothing is skipped of/from the {string} process', nothingIsSkipped);
4747
Then('nothing is skipped', () => nothingIsSkipped('main'));
4848

4949
function assertEventIsTimeout(processName: string) {

src/assert-state.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { DataTable, Then } from '@cucumber/cucumber';
2-
import { hasEnded } from '@letsflow/core/process';
32
import { expect } from "chai";
43
import { world } from "./world"
54
import { parseData } from "./utils"

src/assert-vars.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DataTable, Then } from "@cucumber/cucumber";
1+
import { Then } from "@cucumber/cucumber";
22
import { expect } from "chai";
33
import getValue from 'get-value';
44
import { world } from "./world"
@@ -33,5 +33,13 @@ function assertTag(processName: string, tag: string) {
3333

3434
expect(process.tags).to.include(tag, `The process does not have the tag "${tag}"`);
3535
}
36-
Then('the {string} process has tag {string}', assertTag);
37-
Then('the process has tag {string}', (tag) => assertTag('main', tag));
36+
Then('the {string} process has (the )tag {string}', assertTag);
37+
Then('the process has (the )tag {string}', (tag) => assertTag('main', tag));
38+
39+
function assertNotTag(processName: string, tag: string) {
40+
const process = world.getProcess(processName);
41+
42+
expect(process.tags).to.not.include(tag, `The process does have the tag "${tag}"`);
43+
}
44+
Then('the {string} process doesn\'t have (the )tag {string}', assertNotTag);
45+
Then('the process doesn\'t have (the )tag {string}', (tag) => assertNotTag('main', tag));

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './world';

src/timeout.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ function timePasses(seconds: number) {
77
world.setProcess(processName, timeout(process, { timePassed: seconds }));
88
});
99
}
10-
When('{time} pass', timePasses);
11-
When('{time} passes', timePasses);
10+
When('{time} pass(es)', timePasses);
1211

1312
function timePassesFor(seconds: number, processName: string) {
1413
const process = world.getProcess(processName);
1514
world.setProcess(processName, timeout(process, { timePassed: seconds }));
1615
}
17-
When('{time} pass for the {string} process', timePassesFor);
18-
When('{time} passes for the {string} process', timePassesFor);
16+
When('{time} pass(es) for the {string} process', timePassesFor);

0 commit comments

Comments
 (0)