Skip to content

♻️ Use switch cases instead of if/else #17

♻️ Use switch cases instead of if/else

♻️ Use switch cases instead of if/else #17

Workflow file for this run

name: CI
on: ['push', 'pull_request']
jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
experimental: [false]
runtime: [node, deno, bun]
version: ["latest"]
pm: [npm, pnpm, yarn]
exclude:
- runtime: bun
pm: pnpm
- runtime: bun
pm: yarn
- runtime: deno
pm: pnpm
- runtime: deno
pm: yarn
name: 👷 Panam CI on ${{ matrix.runtime }}-${{ matrix.version }} under ${{ matrix.os }} using ${{ matrix.pm }}
timeout-minutes: 60
steps:
- name: 🚚 Checkout repository
uses: actions/checkout@v4
- name: 🐳 Set up Node.js
if: matrix.runtime == 'node'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
- name: 🦕 Set up Deno
if: matrix.runtime == 'deno'
uses: denoland/setup-deno@v2
with:
deno-version: ${{ matrix.version }}
- name: 🍞 Set up Bun
if: matrix.runtime == 'bun'
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ matrix.version }}
- name: 📦 Install dependencies
run: |
case "${{ inputs.runtime }}" in
"node")
echo "⚙️ Installing ${{ matrix.pm }} dependencies"
if [[ "${{ matrix.pm }}" == "yarn" ]]; then
YARN_VERSION=$(yarn --version)
jq ".packageManager = \"yarn@$YARN_VERSION\"" package.json > yarn-package.json
mv package.json main-package.json
mv yarn-package.json package.json
fi
corepack enable
corepack prepare ${{ matrix.pm }}@latest --activate
if [[ "${{ matrix.pm }}" == "npm" ]]; then
npm install --legacy-peer-deps
else
${{ matrix.pm }} install
fi
;;
"deno")
echo "⚙️ Installing Deno dependencies"
deno install
;;
"bun")
echo "⚙️ Installing Bun dependencies"
bun install
;;
esac
shell: bash
- name: 🔍 Run tests
run: |
echo "🧪 Running tests for ${{ matrix.runtime }}..."
case "${{ inputs.runtime }}" in
"node")
${{ matrix.pm }} run test
;;
"deno")
deno task test
;;
"bun")
bun run test
;;
esac
shell: bash
- name: 🎉 CI completed successfully!
run: |
echo "✅ All tests passed for ${{ matrix.runtime }} on ${{ matrix.os }} using ${{ matrix.pm }}!"
if [[ "${{ matrix.pm }}" == "yarn" ]]; then
mv main-package.json package.json
fi
shell: bash