Skip to content

Commit

Permalink
chore: typescript CI matrix (#68) (#118)
Browse files Browse the repository at this point in the history
### CI/CD
- Added matrices to test Zimic's compatibility with Node.js 18 and 20
and TypeScript 4.7 to 5.4.

Closes #68;
  • Loading branch information
diego-aquino authored Mar 29, 2024
1 parent b3acf7a commit 67757dc
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 46 deletions.
22 changes: 16 additions & 6 deletions .github/actions/zimic-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ runs:
id: install-dependencies
shell: bash
run: |
workspaceRootInstallFlag='--filter zimic-root'
function composeFilterOptions() {
filterEntries=${*}
filterOptions=()
Expand All @@ -82,13 +80,25 @@ runs:
echo "${filterOptions[@]}"
}
partialInstallFlag="$(composeFilterOptions ${{ inputs.install }})"
installFlag="$workspaceRootInstallFlag $partialInstallFlag"
echo "install-filters=$installFlag" >> $GITHUB_OUTPUT
if [[ '${{ inputs.install }}' == '' ]]; then
workspaceRootInstallFlag=''
partialInstallFlag=''
installFlag=''
else
workspaceRootInstallFlag='--filter zimic-root'
partialInstallFlag="$(composeFilterOptions ${{ inputs.install }})"
installFlag="$workspaceRootInstallFlag $partialInstallFlag"
fi
echo "install-filters=$installFlag" >> $GITHUB_OUTPUT
pnpm install --prefer-offline --frozen-lockfile --ignore-scripts $installFlag
buildFlag="$(composeFilterOptions ${{ inputs.build }})"
if [[ '${{ inputs.build }}' == '' ]]; then
buildFlag=''
else
buildFlag="$(composeFilterOptions ${{ inputs.build }})"
fi
echo "build-filters=$buildFlag" >> $GITHUB_OUTPUT
NODE_ENV='${{ inputs.build-node-env }}' pnpm turbo build $buildFlag
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
- 18
- 20

env:
NODE_VERSION: ${{ matrix.node-version }}

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
121 changes: 103 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ concurrency:

env:
CI: true
IS_PULL_REQUEST_TO_MAIN:
${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && 'true' || 'false' }}
TURBO_LOG_ORDER: stream
TURBO_TOKEN:
${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') &&
Expand All @@ -28,20 +30,13 @@ env:
"{./packages/*}[HEAD^1]..."' || './packages/*' }}

jobs:
ci:
name: CI
ci-general:
name: CI General
runs-on: ubuntu-latest
timeout-minutes: 12

strategy:
fail-fast: false
matrix:
node-version:
- 18
- 20
timeout-minutes: 10

env:
NODE_VERSION: ${{ matrix.node-version }}
NODE_VERSION: 20

steps:
- name: Checkout code
Expand All @@ -53,33 +48,123 @@ jobs:
id: zimic-setup
uses: ./.github/actions/zimic-setup
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ env.NODE_VERSION }}
turbo-token: ${{ env.TURBO_TOKEN }}
turbo-team: ${{ env.TURBO_TEAM }}
install: ${{ env.INSTALL_OPTIONS }}
build: ${{ env.BUILD_OPTIONS }}
build-node-env:
${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && 'development'
|| 'production' }}
build-node-env: ${{ env.IS_PULL_REQUEST_TO_MAIN == 'false' && 'development' || 'production' }}
install-playwright-browsers: true

- name: Check formatting style
uses: ./.github/actions/zimic-style-check
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ env.NODE_VERSION }}

- name: Lint code and check types
run: |
pnpm turbo \
types:check lint:turbo \
--continue \
--concurrency 100% \
${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && steps.zimic-setup.outputs.install-filters || '' }}
${{ steps.zimic-setup.outputs.install-filters }}
ci-node:
name: CI Node.js
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
node-version:
- 18
- 20

env:
NODE_VERSION: ${{ matrix.node-version }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup Zimic
id: zimic-setup
uses: ./.github/actions/zimic-setup
with:
node-version: ${{ env.NODE_VERSION }}
turbo-token: ${{ env.TURBO_TOKEN }}
turbo-team: ${{ env.TURBO_TEAM }}
install: ${{ env.INSTALL_OPTIONS }}
build: ${{ env.BUILD_OPTIONS }}
build-node-env: ${{ env.IS_PULL_REQUEST_TO_MAIN == 'false' && 'development' || 'production' }}
install-playwright-browsers: true

- name: Run tests
run: |
pnpm turbo \
test:turbo \
--continue \
--concurrency 100% \
${{ !(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && steps.zimic-setup.outputs.install-filters || '' }}
${{ steps.zimic-setup.outputs.install-filters }}
ci-typescript:
name: CI TypeScript
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
typescript-version:
- 4.7
- 4.8
- 4.9
- 5.0
- 5.1
- 5.2
- 5.3
- 5.4

env:
NODE_VERSION: 20
TYPESCRIPT_VERSION: ${{ matrix.typescript-version }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup Zimic
id: zimic-setup
uses: ./.github/actions/zimic-setup
with:
node-version: ${{ env.NODE_VERSION }}
turbo-token: ${{ env.TURBO_TOKEN }}
turbo-team: ${{ env.TURBO_TEAM }}
install: ${{ env.INSTALL_OPTIONS }}
build: ${{ env.BUILD_OPTIONS }}
build-node-env: ${{ env.IS_PULL_REQUEST_TO_MAIN == 'false' && 'development' || 'production' }}
install-playwright-browsers: false

- name: Set TypeScript version
run: |
pnpm update \
typescript@${{ matrix.typescript-version }} \
--recursive \
${{ steps.zimic-setup.outputs.install-filters }} \
--filter !zimic \
--filter !@zimic/*
- name: Check types
run: |
pnpm turbo \
types:check \
--continue \
--concurrency 100% \
${{ steps.zimic-setup.outputs.install-filters }} \
--filter !zimic \
--filter !@zimic/*
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function superagentAsFetch(request: Request): Promise<Response> {
throw error;
}

const superagentResponse = error.response as SuperagentResponse;
const { response: superagentResponse } = error as Error & { response: SuperagentResponse };

return new Response(superagentResponse.text, {
status: superagentResponse.status,
Expand Down
3 changes: 1 addition & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"devDependencies": {
"@zimic/eslint-config-node": "workspace:*",
"@zimic/lint-staged-config": "workspace:*",
"@zimic/tsconfig": "workspace:*",
"typescript": "^5.4.3"
"@zimic/tsconfig": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/with-jest-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"fastify": "^4.26.1",
"fastify": "4.23.2",
"zimic": "latest",
"zod": "^3.22.4"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vitest-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"fastify": "^4.26.1",
"fastify": "4.23.2",
"zimic": "latest",
"zod": "^3.22.4"
},
Expand Down
29 changes: 13 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://turbo.build/schema.json",
"globalEnv": ["NODE_ENV", "NODE_VERSION"],
"globalEnv": ["NODE_ENV", "NODE_VERSION", "TYPESCRIPT_VERSION"],
"pipeline": {
"dev": {
"cache": false,
Expand Down

0 comments on commit 67757dc

Please sign in to comment.