Skip to content

Commit d574612

Browse files
committed
Run RTK publish CI examples on built artifact
1 parent d698e38 commit d574612

File tree

2 files changed

+84
-10
lines changed

2 files changed

+84
-10
lines changed

.github/workflows/test.yml

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: CI
22

33
on:
44
push:
@@ -27,29 +27,26 @@ jobs:
2727
- name: Install deps
2828
run: yarn install
2929

30-
# Read existing version, reuse that, add a Git short hash
31-
# - name: Set build version to Git commit
32-
# run: node scripts/writeGitVersion.js $(git rev-parse --short HEAD)
30+
# Read existing version, reuse that, add a Git short hash
31+
- name: Set build version to Git commit
32+
run: node scripts/writeGitVersion.js $(git rev-parse --short HEAD)
3333

34-
# - name: Check updated version
35-
# run: jq .version package.json
34+
- name: Check updated version
35+
run: jq .version package.json
3636

3737
- name: Run linter
3838
run: yarn lint
3939

4040
- name: Run tests
4141
run: yarn test
4242

43-
- name: Compile
44-
run: yarn build
45-
4643
- name: Pack
4744
run: yarn pack
4845

4946
- uses: actions/upload-artifact@v2
5047
with:
5148
name: package
52-
path: packages/toolkit/package.tgz
49+
path: ./package.tgz
5350

5451
test-types:
5552
name: Test Types with TypeScript ${{ matrix.ts }}
@@ -82,3 +79,66 @@ jobs:
8279
run: |
8380
yarn tsc --version
8481
yarn test:typescript
82+
83+
test-published-artifact:
84+
name: Test Published Artifact ${{ matrix.example }}
85+
86+
needs: [build]
87+
runs-on: ubuntu-latest
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
node: ['16.x']
92+
example: [
93+
'cra4',
94+
'cra5',
95+
'next',
96+
'vite'
97+
'node-standard',
98+
'node-esm',
99+
'are-the-types-wrong',
100+
]
101+
steps:
102+
- name: Checkout repo
103+
uses: actions/checkout@v2
104+
105+
- name: Use node ${{ matrix.node }}
106+
uses: actions/setup-node@v2
107+
with:
108+
node-version: ${{ matrix.node }}
109+
cache: 'yarn'
110+
111+
- name: Clone RTK repo
112+
run: git clone https://github.com/reduxjs/redux-toolkit.git ./redux-toolkit
113+
114+
- name: Check folder contents
115+
run: ls -l .
116+
117+
- name: Install deps
118+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
119+
run: yarn install
120+
121+
- uses: actions/download-artifact@v2
122+
with:
123+
name: package
124+
path: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
125+
126+
- name: Check folder contents
127+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
128+
run: ls -l .
129+
130+
- name: Install Redux-Thunk build artifact
131+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
132+
run: yarn add ./package.tgz
133+
134+
- name: Show installed package versions
135+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
136+
run: yarn info redux-thunk && yarn why redux-thunk
137+
138+
- name: Build example
139+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
140+
run: yarn build
141+
142+
- name: Run test step
143+
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
144+
run: yarn test

scripts/writeGitVersion.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import path from 'path'
2+
import fs from 'fs'
3+
import { fileURLToPath } from 'node:url'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
7+
8+
const gitRev = process.argv[2]
9+
10+
const packagePath = path.join(__dirname, '../package.json')
11+
const pkg = JSON.parse(fs.readFileSync(packagePath))
12+
13+
pkg.version = `${pkg.version}-${gitRev}`
14+
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2))

0 commit comments

Comments
 (0)