setup-cpp/.github/workflows/CI.yml

283 lines
6.8 KiB
YAML
Raw Normal View History

2021-09-14 14:51:51 +08:00
name: CI
on:
pull_request:
push:
branches:
- master
- main
2021-09-18 20:12:22 +08:00
- dev
2022-10-20 09:16:32 +08:00
tags:
- "*"
2021-09-14 14:51:51 +08:00
jobs:
Build:
runs-on: ubuntu-22.04
name: Build
2022-11-05 11:20:22 +08:00
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
2021-09-14 14:51:51 +08:00
strategy:
fail-fast: false
matrix:
os:
2022-07-22 15:20:33 +08:00
- ubuntu-22.04
2023-04-06 22:40:42 +08:00
node:
2023-07-16 06:41:58 +08:00
- 20
2023-04-25 04:24:44 +08:00
pnpm:
- 8
2021-09-14 14:51:51 +08:00
steps:
- uses: actions/checkout@v4
2021-09-14 14:51:51 +08:00
- name: Cache
2022-08-22 15:00:57 +08:00
uses: actions/cache@v3
2021-09-14 14:51:51 +08:00
with:
path: |
~/.pnpm-store
D:\.pnpm-store
2023-07-16 06:50:55 +08:00
./node_modules
./.parcel-cache
2022-08-04 14:09:17 +08:00
key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
2021-09-14 14:51:51 +08:00
restore-keys: |
2022-08-04 14:09:17 +08:00
"setupcpp-cache-OS:${{ matrix.os }}-"
2021-09-14 14:51:51 +08:00
- name: Setup Node
2022-08-22 15:00:57 +08:00
uses: actions/setup-node@v3
2021-09-14 14:51:51 +08:00
with:
node-version: ${{ matrix.node }}
- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm }}
2023-07-25 05:08:07 +08:00
- name: Install
2021-09-14 14:51:51 +08:00
run: |
pnpm install
2023-07-25 05:08:07 +08:00
- name: Build
run: |
pnpm build
pnpm build.docker_tests
2021-09-14 14:51:51 +08:00
- name: Lint
run: |
pnpm run test.lint
- name: Upload Dist
uses: actions/upload-artifact@v3
with:
name: dist
path: |
./dist
./packages/*/dist
./dev/docker/__tests__/
retention-days: 1
2023-07-25 05:08:07 +08:00
BuildExecutable:
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@v4
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: dist
- 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 }}
2023-07-25 05:08:07 +08:00
- name: Cache node_modules
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
./node_modules
key: "setupcpp-node_modules-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: |
"setupcpp-node_modules-cache-OS:${{ matrix.os }}-"
- name: Install
run: |
pnpm install
2023-04-25 04:50:53 +08:00
# Create self-contained executable that bundles Nodejs
- name: Create Executable
run: |
pnpm run pack.exe
- name: Upload Executables
2023-04-25 04:50:53 +08:00
uses: actions/upload-artifact@v3
with:
name: exe
2023-04-25 04:50:53 +08:00
path: |
./exe
retention-days: 1
Test:
2023-07-25 05:08:07 +08:00
name: Test-${{ matrix.os }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
needs: [Build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-2022
- windows-2019
- ubuntu-22.04
- ubuntu-20.04
- macos-12
- macos-11
node:
- 20
pnpm:
- 8
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Download Dist
uses: actions/download-artifact@v3
with:
name: dist
- 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 }}
2023-07-25 05:08:07 +08:00
- name: Cache node_modules
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
./node_modules
key: "setupcpp-node_modules-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: |
"setupcpp-node_modules-cache-OS:${{ matrix.os }}-"
- name: Install
run: |
pnpm install
2023-07-25 05:08:07 +08:00
# - name: Setup SSH debugging session
# uses: mxschmitt/action-tmate@v3
- name: Tests
if: ${{ !contains(github.event.head_commit.message, '[skip test]') }}
run: |
pnpm run test
env:
RUNNER_OS_NAME: ${{ matrix.os }}
- name: Setup Node 12
uses: actions/setup-node@v3
with:
node-version: 12
- name: Smoke Test Node 12
run: |
2023-07-16 06:41:58 +08:00
node ./dist/legacy/setup-cpp.js --help
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Smoke Test Node 16
run: |
node ./dist/actions/setup-cpp.js --help
2021-09-18 20:12:22 +08:00
Docker:
2023-07-25 05:08:07 +08:00
name: Test-${{ matrix.container }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
needs: [Build]
2021-09-18 20:12:22 +08:00
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
2021-09-18 20:12:22 +08:00
matrix:
os:
- ubuntu-22.04
node:
2023-07-16 06:41:58 +08:00
- 20
pnpm:
- 8
2022-02-15 17:23:01 +08:00
container:
2023-07-16 08:15:31 +08:00
- "ubuntu.dockerfile"
- "fedora.dockerfile"
- "arch.dockerfile"
- "ubuntu-mingw.dockerfile"
# - "fedora-mingw.dockerfile"
# - "arch-mingw.dockerfile"
2021-09-18 20:12:22 +08:00
steps:
- uses: actions/checkout@v4
2021-09-18 20:12:22 +08:00
with:
submodules: true
- name: Download Dist
uses: actions/download-artifact@v3
with:
name: dist
2021-09-18 20:12:22 +08:00
- name: Build
id: docker_build
run: |
2023-07-16 08:15:31 +08:00
docker build -f ./dev/docker/__tests__/${{ matrix.container }} -t setup-cpp .
Release:
if: startsWith(github.ref, 'refs/tags/')
2023-07-25 05:08:07 +08:00
needs: [Build, BuildExecutable, 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 ./dist/ ./dist-artifacts
mv -v ./dist-artifacts/* ./
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/