Skip to content

Commit

Permalink
Run RTK publish CI examples on built artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Mar 25, 2023
1 parent d698e38 commit d574612
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 10 deletions.
80 changes: 70 additions & 10 deletions .github/workflows/test.yml
@@ -1,4 +1,4 @@
name: Tests
name: CI

on:
push:
Expand Down Expand Up @@ -27,29 +27,26 @@ jobs:
- name: Install deps
run: yarn install

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

# - name: Check updated version
# run: jq .version package.json
- name: Check updated version
run: jq .version package.json

- name: Run linter
run: yarn lint

- name: Run tests
run: yarn test

- name: Compile
run: yarn build

- name: Pack
run: yarn pack

- uses: actions/upload-artifact@v2
with:
name: package
path: packages/toolkit/package.tgz
path: ./package.tgz

test-types:
name: Test Types with TypeScript ${{ matrix.ts }}
Expand Down Expand Up @@ -82,3 +79,66 @@ jobs:
run: |
yarn tsc --version
yarn test:typescript
test-published-artifact:
name: Test Published Artifact ${{ matrix.example }}

needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['16.x']
example: [
'cra4',
'cra5',
'next',
'vite'
'node-standard',
'node-esm',
'are-the-types-wrong',
]
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'yarn'

- name: Clone RTK repo
run: git clone https://github.com/reduxjs/redux-toolkit.git ./redux-toolkit

- name: Check folder contents
run: ls -l .

- name: Install deps
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn install

- uses: actions/download-artifact@v2
with:
name: package
path: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}

- name: Check folder contents
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: ls -l .

- name: Install Redux-Thunk build artifact
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn add ./package.tgz

- name: Show installed package versions
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn info redux-thunk && yarn why redux-thunk

- name: Build example
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn build

- name: Run test step
working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: yarn test
14 changes: 14 additions & 0 deletions scripts/writeGitVersion.js
@@ -0,0 +1,14 @@
import path from 'path'
import fs from 'fs'
import { fileURLToPath } from 'node:url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const gitRev = process.argv[2]

const packagePath = path.join(__dirname, '../package.json')
const pkg = JSON.parse(fs.readFileSync(packagePath))

pkg.version = `${pkg.version}-${gitRev}`
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2))

0 comments on commit d574612

Please sign in to comment.