forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ci): add build product checking for prs (element-plus#6558)
* test(ci): add build product checking for prs - Add build product testing to the CI * Fix error syntax * Tweak with output table
- Loading branch information
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: ${{ steps.diff.outputs.content }} | ||
body-include: '<sub>Generated with' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ packages/element-plus/version.ts | |
*.local | ||
cypress/screenshots/* | ||
cypress/videos/* | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |