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 2f89cea
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 9 deletions.
77 changes: 68 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: CI

on:
push:
Expand Down Expand Up @@ -27,22 +27,19 @@ 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

Expand Down Expand Up @@ -82,3 +79,65 @@ 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',
]
defaults:
run:
working-directory: ./examples/publish-ci/${{ matrix.example }}
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

- name: Select example
run: cd redux-toolkit/examples/publish-ci/${{ matrix.example }}

- name: Install deps
run: yarn install

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

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

- name: Install Redux-Thunk build artifact
run: yarn add ./package.tgz

- name: Show installed package versions
run: >
yarn info redux-thunk
yarn why redux-thunk
- name: Build example
run: yarn build

- name: Run test step
run: yarn test
14 changes: 14 additions & 0 deletions scripts/writeGitVersion.js
Original file line number Diff line number Diff line change
@@ -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 2f89cea

Please sign in to comment.