ci: shared build for all the tests - rewrite the CI workflow

This commit is contained in:
Amin Yahyaabadi 2023-07-24 13:59:56 -07:00
parent 0b79280662
commit 697fc17c87
17 changed files with 189 additions and 115 deletions

View File

@ -10,9 +10,113 @@ on:
- "*"
jobs:
Build:
runs-on: ubuntu-22.04
name: Build
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
node:
- 20
pnpm:
- 8
steps:
- uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
./node_modules
./.parcel-cache
key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: |
"setupcpp-cache-OS:${{ matrix.os }}-"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm }}
- name: Install and build
run: |
pnpm install
pnpm build.docker_tests
- name: Upload Dist
uses: actions/upload-artifact@v3
with:
name: dist
path: |
./dist
./dev/docker/__tests__/
retention-days: 1
Build_Executable:
name: Build_Executable-${{ matrix.os }}
needs: [Build]
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-2022
- ubuntu-22.04
- macos-12
node:
- 20
pnpm:
- 8
steps:
- uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: dist
- name: Place Artifacts
shell: bash
run: |
mv -v artifact/* ./
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm }}
# Create self-contained executable that bundles Nodejs
- name: Create Executable
run: |
pnpm run pack.exe
- name: Upload Executables
uses: actions/upload-artifact@v3
with:
name: exe
path: |
./exe
retention-days: 1
Test:
name: ${{ matrix.os }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') || !contains(github.event.head_commit.message, '[skip test]') }}
needs: [Build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@ -33,16 +137,14 @@ jobs:
with:
submodules: true
- name: Cache
uses: actions/cache@v3
- name: Download Dist
uses: actions/download-artifact@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
./node_modules
key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: |
"setupcpp-cache-OS:${{ matrix.os }}-"
name: dist
- name: Place Dist
shell: bash
run: |
mv -v artifact/* ./
- name: Setup Node
uses: actions/setup-node@v3
@ -54,33 +156,17 @@ jobs:
with:
version: ${{ matrix.pnpm }}
- name: Install and build
run: |
pnpm install
# - name: Setup SSH debugging session
# uses: mxschmitt/action-tmate@v3
- name: Install
run: |
pnpm install
- name: Test
if: "${{ !contains(github.event.head_commit.message, '[skip test]') }}"
run: |
pnpm run test
# Create self-contained executable that bundles Nodejs
- name: Create Executable
if: "${{ contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12') }}"
run: |
pnpm run pack.exe
- name: Upload Artifacts
if: ${{ (startsWith(github.ref, 'refs/tags/')) && contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12') }}
uses: actions/upload-artifact@v3
with:
path: |
./exe
./dist
retention-days: 1
- name: Setup Node 12
uses: actions/setup-node@v3
with:
@ -97,38 +183,10 @@ jobs:
run: |
node ./dist/actions/setup-cpp.js --help
Release:
needs: Test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Place Artifacts
run: |
mv -v artifact/* ./
chmod +x -R ./exe/
- name: Draft the release
uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
gzip: folders
draft: true
files: >
./exe/setup-cpp-x64-windows.exe
./exe/setup-cpp-x64-linux
./exe/setup-cpp-x64-macos
./dist/legacy/setup-cpp.js
./dist/legacy/setup-cpp.js.map
./dist/legacy/
./dist/actions/
./dist/modern/
Docker:
name: ${{ matrix.container }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip test]') }}
needs: [Build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@ -151,33 +209,48 @@ jobs:
with:
submodules: true
- name: Cache
uses: actions/cache@v3
- name: Download Dist
uses: actions/download-artifact@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
./node_modules
key: "setupcpp-docker-cache-OS:${{ matrix.os }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: |
"setupcpp-docker-cache-OS:${{ matrix.os }}"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm }}
- name: Install and build
name: dist
- name: Place Dist
shell: bash
run: |
pnpm install
pnpm build.docker_tests
mv -v artifact/* ./
- name: Build
id: docker_build
run: |
docker build -f ./dev/docker/__tests__/${{ matrix.container }} -t setup-cpp .
Release:
if: startsWith(github.ref, 'refs/tags/')
needs: [Build, Build_Executable, Test, Docker]
runs-on: ubuntu-22.04
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v3
- name: Place Artifacts
shell: bash
run: |
mv -v artifact/dist/* ./
mv -v artifact/exe/* ./
chmod +x -R ./exe/
- name: Draft the release
uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
gzip: folders
draft: true
files: >
./exe/setup-cpp-x64-windows.exe
./exe/setup-cpp-x64-linux
./exe/setup-cpp-x64-macos
./dist/legacy/setup-cpp.js
./dist/legacy/setup-cpp.js.map
./dist/legacy/
./dist/actions/
./dist/modern/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,10 +28,11 @@
"tsconfig.json"
],
"scripts": {
"build": "shx rm -rf dist/ && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern && run-p lint.tsc build.parcel copy.matchers",
"build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers",
"build.packages": "pnpm run -r build",
"build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x numerous && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
"clean": "shx rm -rf ./dist ./exe ./packages/*/dist/ && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern ",
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions copy.matchers.modern",
"copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/",
"copy.matchers.actions": "shx cp ./src/gcc/gcc_matcher.json ./dist/actions/ && shx cp ./src/msvc/msvc_matcher.json ./dist/actions/ && shx cp ./src/python/python_matcher.json ./dist/actions/ && shx cp ./src/llvm/llvm_matcher.json ./dist/actions/",
@ -45,7 +46,7 @@
"lint.prettier": "prettier --list-different --write .",
"lint.tsc": "tsc --noEmit",
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.mjs",
"prepare": "pnpm run -r build && pnpm run -w build && rm ./dist/tsconfig.tsbuildinfo",
"prepublishOnly": "rm ./dist/tsconfig.tsbuildinfo",
"start.docker": "docker run -t setup-cpp .",
"start.docker.arch": "docker run -t setup-cpp:arch .",
"start.docker.fedora": "docker run -t setup-cpp:fedora .",