Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 13 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 169 additions & 74 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,21 @@ on:
- "*"

jobs:
Test:
name: ${{ matrix.os }}
Build:
runs-on: ubuntu-22.04
name: Build
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
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@v3
with:
submodules: true

- name: Cache
uses: actions/cache@v3
Expand All @@ -40,6 +33,7 @@ jobs:
~/.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 }}-"
Expand All @@ -54,33 +48,152 @@ jobs:
with:
version: ${{ matrix.pnpm }}

- name: Install and build
- name: Install
run: |
pnpm install

# - name: Setup SSH debugging session
# uses: mxschmitt/action-tmate@v3
- name: Build
run: |
pnpm build
pnpm build.docker_tests

- name: Test
if: "${{ !contains(github.event.head_commit.message, '[skip test]') }}"
- name: Lint
run: |
pnpm run test
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

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@v3

- 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 }}

- 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

# 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') }}
- name: Upload Executables
uses: actions/upload-artifact@v3
with:
name: exe
path: |
./exe
./dist
retention-days: 1

Test:
name: Test-${{ matrix.os }}
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
matrix:
os:
- windows-2022
- windows-2019
- ubuntu-22.04
- ubuntu-20.04
- macos-12
- macos-11
node:
- 20
pnpm:
- 8
steps:
- uses: actions/checkout@v3
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 }}

- 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

# - name: Setup SSH debugging session
# uses: mxschmitt/action-tmate@v3

- name: Tests
run: |
pnpm run test

- name: Setup Node 12
uses: actions/setup-node@v3
with:
Expand All @@ -97,38 +210,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/[email protected]
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 }}
name: Test-${{ 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
Expand All @@ -151,33 +236,43 @@ jobs:
with:
submodules: true

- name: Cache
uses: actions/cache@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
- name: Download Dist
uses: actions/download-artifact@v3
with:
version: ${{ matrix.pnpm }}

- name: Install and build
run: |
pnpm install
pnpm build.docker_tests
name: dist

- 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, 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/* ./
mv -v ./exe/* ./
chmod +x -R ./exe/

- name: Draft the release
uses: meeDamian/[email protected]
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/
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ You will need [`pnpm`](https://pnpm.io/installation) to build and test `setup-cp
pnpm install
```

To avoid permenant changes to your system, you can use the test docker images under `./dev/docker/__tests__`.

Before running the tests locally, backup your environment variables because faulty code might corrupt the environment.

<https://stackoverflow.com/a/5147185/7910299>
Expand Down
2 changes: 1 addition & 1 deletion dev/docker/__tests__/generate-docker-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main() {

// write the new file in dev/docker/__tests__
await writeFile(`./dev/docker/__tests__/${dockerFile}.dockerfile`, newDockerFileContent)
})
}),
)
}

Expand Down
4 changes: 2 additions & 2 deletions dev/scripts/pack-exe.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function main() {
"--",
`{{caxa}}/node_modules/.bin/node${exe}`,
`{{caxa}}/setup-cpp.js`,
])
)
]),
),
)
}

Expand Down
6 changes: 0 additions & 6 deletions dist/actions/actions_python.72dce301.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/actions/actions_python.72dce301.js.map

This file was deleted.

7 changes: 7 additions & 0 deletions dist/actions/actions_python.dac7d648.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/actions/actions_python.dac7d648.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dist/legacy/actions_python.30df6221.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/legacy/actions_python.30df6221.js.map

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions dist/legacy/actions_python.a52d4819.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/legacy/actions_python.a52d4819.js.map

This file was deleted.

20 changes: 10 additions & 10 deletions dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions dist/modern/actions_python.62d0ce0e.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/modern/actions_python.62d0ce0e.js.map

This file was deleted.

7 changes: 7 additions & 0 deletions dist/modern/actions_python.d4cc9106.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/modern/actions_python.d4cc9106.js.map

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions jest.config.mjs

This file was deleted.

17 changes: 17 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Config } from "jest"

const jestConfig: Config = {
testMatch: ["**/*.test.ts"],
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts", ".tsx", ".jsx"],
transformIgnorePatterns: [], // transform node_modules
transform: {
"^.+\\.(t|j)sx?$": "@swc/jest",
},
// coverage
collectCoverageFrom: ["src/**/*.{ts,tsx,js,jsx}"],
coveragePathIgnorePatterns: ["assets", ".css.d.ts"],
verbose: true,
}

export default jestConfig
Loading