mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
test(ci): add build product checking for prs (#6558)
* test(ci): add build product checking for prs - Add build product testing to the CI * Fix error syntax * Tweak with output table
This commit is contained in:
parent
2db400c73a
commit
9172120d52
62
.github/workflows/build-product.yml
vendored
Normal file
62
.github/workflows/build-product.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: Build Product 👮♂️
|
||||||
|
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Build Product Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Add dev branch
|
||||||
|
run: git branch dev origin/dev
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v2
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '16'
|
||||||
|
|
||||||
|
- name: Cache ~/.pnpm-store
|
||||||
|
uses: actions/cache@v2
|
||||||
|
env:
|
||||||
|
cache-name: cache-pnpm-store
|
||||||
|
with:
|
||||||
|
path: ~/.pnpm-store
|
||||||
|
key: ${{ runner.os }}-${{ matrix.node-version }}-test-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-${{ matrix.node-version }}-test-${{ env.cache-name }}-
|
||||||
|
${{ runner.os }}-${{ matrix.node-version }}-test-
|
||||||
|
${{ runner.os }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm i --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Local build
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Check build product
|
||||||
|
run: sh -c ./scripts/file-check.sh
|
||||||
|
|
||||||
|
- name: Diff gen
|
||||||
|
run: pnpm diff:table
|
||||||
|
|
||||||
|
- name: Read diff file
|
||||||
|
id: diff
|
||||||
|
uses: juliangruber/read-file-action@v1
|
||||||
|
with:
|
||||||
|
path: ./tmp/diff.md
|
||||||
|
|
||||||
|
- name: Set comment
|
||||||
|
uses: actions-cool/maintain-one-comment@v2.0.2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
body: ${{ steps.diff.outputs.content }}
|
||||||
|
body-include: '<sub>Generated with'
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@ packages/element-plus/version.ts
|
|||||||
*.local
|
*.local
|
||||||
cypress/screenshots/*
|
cypress/screenshots/*
|
||||||
cypress/videos/*
|
cypress/videos/*
|
||||||
|
tmp
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
"dev": "pnpm -C play dev",
|
"dev": "pnpm -C play dev",
|
||||||
"gen": "bash ./scripts/gc.sh",
|
"gen": "bash ./scripts/gc.sh",
|
||||||
"gen:version": "sucrase-node scripts/gen-version.ts",
|
"gen:version": "sucrase-node scripts/gen-version.ts",
|
||||||
|
"diff:table": "sucrase-node scripts/build-table.ts",
|
||||||
"update:version": "sucrase-node scripts/update-version.ts",
|
"update:version": "sucrase-node scripts/update-version.ts",
|
||||||
"clean": "pnpm run clean:dist && pnpm run clean -r --stream",
|
"clean": "pnpm run clean:dist && pnpm run clean -r --stream",
|
||||||
"clean:dist": "rimraf dist",
|
"clean:dist": "rimraf dist",
|
||||||
|
49
scripts/build-table.ts
Normal file
49
scripts/build-table.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import fs from 'fs/promises'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
let output: string
|
||||||
|
const diffOutput = await fs.readFile(
|
||||||
|
path.resolve(__dirname, '..', 'tmp/diff.txt'),
|
||||||
|
'utf-8'
|
||||||
|
)
|
||||||
|
const fileDiffs = diffOutput
|
||||||
|
.split('\n')
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter((s) => s)
|
||||||
|
.map((s) => s.split(':'))
|
||||||
|
|
||||||
|
if (fileDiffs.length === 0) {
|
||||||
|
output = ''
|
||||||
|
} else {
|
||||||
|
const table = fileDiffs.reduce(
|
||||||
|
(prev, [source, filename]) => {
|
||||||
|
const row = `|${filename}`
|
||||||
|
let status: 'Added 🟢' | 'Removed ⛔️'
|
||||||
|
if (!source.startsWith('./dist')) {
|
||||||
|
status = 'Removed ⛔️'
|
||||||
|
} else {
|
||||||
|
status = 'Added 🟢'
|
||||||
|
}
|
||||||
|
return `${prev}
|
||||||
|
${row}|${status}|`
|
||||||
|
},
|
||||||
|
`| Filename | Status |
|
||||||
|
|:---|:---:|`
|
||||||
|
)
|
||||||
|
|
||||||
|
output = `**Total changed files:** ${fileDiffs.length}
|
||||||
|
|
||||||
|
<details><summary>:information_source: Files have been changed</summary>
|
||||||
|
|
||||||
|
${table}
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<sub>Generated with :heart: by Element Plus bot</sub>`
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.writeFile(path.resolve(__dirname, '..', 'tmp/diff.md'), output)
|
||||||
|
}
|
12
scripts/file-check.sh
Executable file
12
scripts/file-check.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
CURRENT_PUBLISHED_TARBALL="$(npm view element-plus dist.tarball)"
|
||||||
|
|
||||||
|
echo $CURRENT_PUBLISHED_TARBALL
|
||||||
|
|
||||||
|
mkdir -p tmp
|
||||||
|
|
||||||
|
curl -o ./tmp/latest.tgz $CURRENT_PUBLISHED_TARBALL
|
||||||
|
tar zxvf ./tmp/latest.tgz -C ./tmp
|
||||||
|
|
||||||
|
diff -qr ./tmp/package ./dist/element-plus | grep "Only" | cut -c 8- | sort > ./tmp/diff.txt
|
Loading…
Reference in New Issue
Block a user