From 187d470ba6ecd9afb43295035c7eba61ecc498b3 Mon Sep 17 00:00:00 2001 From: developomp Date: Sun, 5 Jan 2025 09:01:40 +0900 Subject: [PATCH] ci: use devenv for testing --- .github/workflows/test.yml | 52 ++++++++++---------------------------- devenv.nix | 5 ++++ 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 819deb4..2d2aeca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,54 +1,30 @@ +# https://devenv.sh/integrations/github-actions name: Test on: push: branches: - master + workflow_dispatch: jobs: test: name: Test runs-on: ubuntu-latest + permissions: + # permissions required for nix caching to work properly + id-token: write + contents: read steps: - - name: Checkout Repo - uses: actions/checkout@master + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: pnpm/action-setup@v2 - with: - version: 9 + - name: Install devenv.sh + run: nix profile install nixpkgs#devenv - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 20 - cache: pnpm + - name: Cache turbo build + uses: dtinth/setup-github-actions-caching-for-turbo@v1 - - name: Store Playwright's Version - run: | - PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//') - echo "Playwright's Version: $PLAYWRIGHT_VERSION" - echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV - - - name: Cache Playwright Browsers for Playwright's Version - id: cache-playwright-browsers - uses: actions/cache@v3 - with: - path: ~/.cache/ms-playwright - key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }} - - - name: Install dependencies - run: pnpm install - - - name: Install playwright browsers - if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' - run: npx playwright install --with-deps - - - name: Build - run: pnpm build - - - name: Run unit tests - run: pnpm test:unit - - - name: Run E2E tests - run: pnpm test:e2e + - run: devenv test - uses: actions/upload-artifact@v3 with: diff --git a/devenv.nix b/devenv.nix index 056a963..a746ac6 100644 --- a/devenv.nix +++ b/devenv.nix @@ -16,6 +16,11 @@ PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS = true; }; + enterTest = '' + pnpm test:unit + pnpm test:e2e + ''; + languages = { # https://devenv.sh/supported-languages/javascript javascript = {