Skip to content

Commit 67c9bf9

Browse files
committed
CI/CD for npm + new error type
1 parent 1a60498 commit 67c9bf9

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed

.github/workflows/merge-main.yaml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: PR Merged -> main
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
7+
jobs:
8+
linting:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/[email protected]
14+
15+
- name: Set up Node.js
16+
uses: actions/[email protected]
17+
with:
18+
node-version: 20
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run ESLint
24+
run: npm run lint
25+
26+
typecheck:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/[email protected]
32+
33+
- name: Set up Node.js
34+
uses: actions/[email protected]
35+
with:
36+
node-version: 20
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: Run typecheck
42+
run: npm run typecheck
43+
44+
build:
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/[email protected]
50+
51+
- name: Set up Node.js
52+
uses: actions/[email protected]
53+
with:
54+
node-version: 20
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Build
60+
run: npm run build
61+
62+
test:
63+
runs-on: ubuntu-latest
64+
65+
steps:
66+
- name: Checkout code
67+
uses: actions/[email protected]
68+
69+
- name: Set up Node.js
70+
uses: actions/[email protected]
71+
with:
72+
node-version: 20
73+
74+
- name: Install dependencies
75+
run: npm ci
76+
77+
- name: Run tests
78+
run: npm run test
79+
80+
publish:
81+
needs: [linting, typecheck, build, test]
82+
runs-on: ubuntu-latest
83+
if: always() && needs.linting.result == 'success' && needs.typecheck.result == 'success' && needs.build.result == 'success' && needs.test.result == 'success'
84+
85+
steps:
86+
- name: Checkout code
87+
uses: actions/[email protected]
88+
89+
- name: Set up Node.js
90+
uses: actions/[email protected]
91+
with:
92+
node-version: 20
93+
registry-url: 'https://registry.npmjs.org'
94+
95+
- name: Install dependencies
96+
run: npm ci
97+
98+
- name: Build
99+
run: npm run build
100+
101+
- name: Check if version changed
102+
id: version-check
103+
run: |
104+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
105+
NPM_VERSION=$(npm view linkedapi-node version 2>/dev/null || echo "0.0.0")
106+
if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
107+
echo "should_publish=true" >> $GITHUB_OUTPUT
108+
echo "Version changed: $NPM_VERSION -> $PACKAGE_VERSION"
109+
else
110+
echo "should_publish=false" >> $GITHUB_OUTPUT
111+
echo "Version unchanged: $PACKAGE_VERSION"
112+
fi
113+
114+
- name: Publish to npm
115+
if: steps.version-check.outputs.should_publish == 'true'
116+
run: npm publish
117+
env:
118+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/pr-main.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: PR Sent -> main
2+
3+
on:
4+
pull_request:
5+
branches: ['main']
6+
7+
jobs:
8+
linting:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/[email protected]
14+
15+
- name: Set up Node.js
16+
uses: actions/[email protected]
17+
with:
18+
node-version: 20
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run ESLint
24+
run: npm run lint
25+
26+
typecheck:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/[email protected]
32+
33+
- name: Set up Node.js
34+
uses: actions/[email protected]
35+
with:
36+
node-version: 20
37+
38+
- name: Install dependencies
39+
run: npm ci
40+
41+
- name: Run typecheck
42+
run: npm run typecheck
43+
44+
build:
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/[email protected]
50+
51+
- name: Set up Node.js
52+
uses: actions/[email protected]
53+
with:
54+
node-version: 20
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Build
60+
run: npm run build
61+
62+
test:
63+
runs-on: ubuntu-latest
64+
65+
steps:
66+
- name: Checkout code
67+
uses: actions/[email protected]
68+
69+
- name: Set up Node.js
70+
uses: actions/[email protected]
71+
with:
72+
node-version: 20
73+
74+
- name: Install dependencies
75+
run: npm ci
76+
77+
- name: Run tests
78+
run: npm run test

src/types/errors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { TOperationName } from '../core';
66
* This error signals that the workflow action failed to complete, but the workflow completed as expected.
77
* Common types:
88
* - personNotFound (sendMessage, syncConversation, checkConnectionStatus, sendConnectionRequest, withdrawConnectionRequest, removeConnection, fetchPerson, nvSendMessage, nvSyncConversation, nvFetchPerson)
9+
* - selfProfileNotAllowed (fetchPerson, nvFetchPerson)
910
* - messagingNotAllowed (sendMessage, nvSendMessage)
1011
* - alreadyPending (sendConnectionRequest)
1112
* - alreadyConnected (sendConnectionRequest)
@@ -23,6 +24,7 @@ import { TOperationName } from '../core';
2324
*/
2425
export const LINKED_API_ACTION_ERROR = {
2526
personNotFound: 'personNotFound',
27+
selfProfileNotAllowed: 'selfProfileNotAllowed',
2628
messagingNotAllowed: 'messagingNotAllowed',
2729
alreadyPending: 'alreadyPending',
2830
alreadyConnected: 'alreadyConnected',

0 commit comments

Comments
 (0)