Skip to content

Commit 3d69520

Browse files
committed
ci: e2e-test via verdaccio
1 parent 1522214 commit 3d69520

File tree

3 files changed

+108
-70
lines changed

3 files changed

+108
-70
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: "verdaccio-actions"
2+
author: "uiolee"
3+
description: "setup a local registry via Verdaccio."
4+
branding:
5+
icon: "archive"
6+
color: "gray-dark"
7+
8+
inputs:
9+
install-global:
10+
description: "whether install verdaccio in global"
11+
required: false
12+
default: "true"
13+
package-manager:
14+
description: "specify which is uesd to install verdaccio"
15+
required: false
16+
default: "npm"
17+
verdaccio-bin:
18+
description: "the path of verdaccio"
19+
required: false
20+
default: "verdaccio"
21+
verdaccio-setup:
22+
description: "whether to setup verdaccio"
23+
required: false
24+
default: "true"
25+
verdaccio-listen:
26+
description: "Define host:port of registry"
27+
required: false
28+
default: "localhost:4873"
29+
verdaccio-config:
30+
description: "Set location of the configuration file"
31+
required: true
32+
default: ""
33+
token-config:
34+
description: "whether to setup token of local registry in npm configuration"
35+
required: false
36+
default: "false"
37+
token-content:
38+
description: "the authtoken of your verdaccio registry"
39+
required: false
40+
token-config-location:
41+
description: "Define the location of token config. passed to `npm set ... --location <token-config-location>`"
42+
required: false
43+
default: "project"
44+
registry-config:
45+
description: "whether to setup registry setting in npm configuration"
46+
required: false
47+
default: "false"
48+
registry-config-location:
49+
description: "Define the location of register config. passed to `npm set ... --location <registry-config-location>`"
50+
required: false
51+
default: "project"
52+
53+
outputs:
54+
listen:
55+
description: "verdaccio listen address"
56+
value: ${{ inputs.verdaccio-listen }}
57+
58+
runs:
59+
using: "composite"
60+
steps:
61+
- name: Install pnpm
62+
uses: pnpm/action-setup@v3
63+
if: ${{ inputs.package-manager == 'pnpm' }}
64+
with:
65+
version: "8"
66+
67+
- name: Install verdaccio global
68+
shell: bash
69+
if: ${{ inputs.install-global == 'true' }}
70+
run: |
71+
${{ inputs.package-manager }} add -g verdaccio verdaccio-memory
72+
73+
- name: Setup verdaccio
74+
shell: bash
75+
if: ${{ inputs.verdaccio-setup == 'true' }}
76+
run: |
77+
nohup ${{ inputs.verdaccio-bin }} --config ${{ inputs.verdaccio-config }} --listen ${{ inputs.verdaccio-listen }} &>.verdaccio.log &
78+
79+
- name: set token
80+
shell: bash
81+
if: ${{ inputs.token-config == 'true' }}
82+
run: |
83+
npm config set //${{ inputs.verdaccio-listen }}/:_authToken ${{ inputs.token-content }} --location ${{ inputs.token-config-location }}
84+
85+
- name: set registry
86+
shell: bash
87+
if: ${{ inputs.registry-config == 'true' }}
88+
run: |
89+
npm config set registry http://${{ inputs.verdaccio-listen }}/ --location ${{ inputs.registry-config-location }}

.github/workflows/build.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
submodules: "recursive"
3333

34-
- uses: pnpm/action-setup@v2
34+
- uses: pnpm/action-setup@v3
3535
name: Install pnpm
3636
with:
3737
version: ${{env.default_pnpm_version}}
@@ -53,10 +53,6 @@ jobs:
5353
run: |
5454
echo -n $(cat .git/modules/hexo-starter/refs/heads/master) > hash
5555
56-
- name: pack
57-
run: |
58-
npm pack
59-
6056
- uses: actions/upload-artifact@v4
6157
with:
6258
retention-days: 1
@@ -65,4 +61,3 @@ jobs:
6561
path: |
6662
bin
6763
hash
68-
*.tgz

.github/workflows/ci.yml

+18-64
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
submodules: "recursive"
3232

33-
- uses: pnpm/action-setup@v2
33+
- uses: pnpm/action-setup@v3
3434
name: Install pnpm
3535
with:
3636
version: ${{env.default_pnpm_version}}
@@ -53,7 +53,7 @@ jobs:
5353
steps:
5454
- uses: actions/checkout@v4
5555

56-
- uses: pnpm/action-setup@v2
56+
- uses: pnpm/action-setup@v3
5757
name: Install pnpm
5858
with:
5959
version: ${{env.default_pnpm_version}}
@@ -74,19 +74,14 @@ jobs:
7474
name: Build
7575
uses: ./.github/workflows/build.yml
7676

77-
test-ve:
78-
name: test-ve
77+
test-e2e:
78+
name: test-e2e
7979
needs: build
8080
runs-on: ${{ matrix.os }}
81-
services:
82-
verdaccio:
83-
image: verdaccio/verdaccio:5
84-
ports:
85-
- 4873:4873
8681
strategy:
8782
matrix:
88-
os: [ubuntu-latest]
89-
pm: ["pnpm", "npm", "yarn"]
83+
os: [ubuntu-latest, windows-latest, macos-latest]
84+
pm: [pnpm, npm, yarn]
9085
fail-fast: false
9186

9287
steps:
@@ -98,7 +93,7 @@ jobs:
9893
with:
9994
name: artifact
10095

101-
- uses: pnpm/action-setup@v2
96+
- uses: pnpm/action-setup@v3
10297
name: Install pnpm
10398
if: ${{ matrix.pm == 'pnpm' }}
10499
with:
@@ -108,70 +103,29 @@ jobs:
108103
with:
109104
node-version: ${{env.default_node_version}}
110105

111-
- name: login to 'verdaccio'
112-
run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873
106+
- name: setup 'verdaccio'
107+
id: verdaccio
108+
uses: ./.github/actions/verdaccio-actions
109+
with:
110+
verdaccio-config: .verdaccio/.verdaccio.yaml
111+
token-config: true
112+
token-content: gHz2lB9wOy+kDV4Cyy+v0w==
113113

114-
- name: version for 'verdaccio'
114+
- name: version for test
115115
run: |
116-
npm version patch --commit-hooks false --git-tag-version false
116+
npm version major --commit-hooks false --git-tag-version false
117117
118118
- name: publish to 'verdaccio'
119119
run: |
120-
npm publish --registry http://localhost:4873
120+
npm publish --registry http://${{ steps.verdaccio.outputs.listen }}
121121
122122
- name: config for test
123123
run: |
124124
mkdir ../.temp
125-
${{ matrix.pm }} config set registry http://localhost:4873/
125+
${{ matrix.pm }} config set registry http://${{ steps.verdaccio.outputs.listen }}
126126
127127
- name: Test via ${{ matrix.pm }}
128128
working-directory: ../.temp/
129129
timeout-minutes: 5
130130
run: |
131131
${{ matrix.pm }} create hexo
132-
133-
test-ln:
134-
name: test-ln
135-
needs: build
136-
runs-on: ${{ matrix.os }}
137-
strategy:
138-
matrix:
139-
os: [windows-latest, macos-latest]
140-
pm: ["pnpm", "npm"]
141-
fail-fast: false
142-
143-
steps:
144-
- uses: actions/checkout@v4
145-
# with:
146-
# submodules: "recursive"
147-
148-
- uses: actions/download-artifact@v4
149-
with:
150-
name: artifact
151-
152-
- uses: pnpm/action-setup@v2
153-
name: Install pnpm
154-
if: ${{ matrix.pm == 'pnpm' }}
155-
with:
156-
version: ${{env.default_pnpm_version}}
157-
158-
- uses: actions/setup-node@v4
159-
with:
160-
node-version: ${{env.default_node_version}}
161-
162-
- name: config for test
163-
run: |
164-
mkdir ../temp
165-
node scripts/getVersion.mjs
166-
167-
- name: Link via ${{ matrix.pm }}
168-
working-directory: ../temp/
169-
timeout-minutes: 5
170-
run: |
171-
${{ matrix.pm }} add ../create-hexo/create-hexo-${{env.version}}.tgz
172-
173-
- name: Test via ${{ matrix.pm }}
174-
working-directory: ../temp/
175-
timeout-minutes: 5
176-
run: |
177-
${{ matrix.pm }} exec create-hexo test

0 commit comments

Comments
 (0)