Skip to content

Commit

Permalink
ci: add release
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuireu committed Sep 11, 2024
1 parent af6b8de commit 7712ca5
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 162 deletions.
106 changes: 53 additions & 53 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
name: E2E Tests - Playwright
name: E2E Tests
on:
workflow_dispatch:
pull_request:
branches: [main]
workflow_dispatch:
pull_request:
branches: [main]
env:
CI: true
E2E_URL: ${{ github.event_name == 'workflow_dispatch' && 'https://biancafiore.me' || 'http://localhost:4321' }}
CI: true
E2E_URL: ${{ github.event_name == 'workflow_dispatch' && 'https://biancafiore.me' || 'http://localhost:4321' }}
jobs:
e2e-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js version from .nvmrc
id: nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Start application (for PRs only)
if: github.event_name != 'workflow_dispatch'
run: |
yarn start &
echo $! > .pidfile
- name: Wait for application to be ready (for PRs only)
if: github.event_name != 'workflow_dispatch'
run: |
echo "Waiting for application to start..."
npx wait-on ${{ env.E2E_URL }}
- name: Run E2E Tests - Playwright for PRs
if: github.event_name == 'pull_request'
run: yarn test:e2e:changed
env:
CI: ${{ env.CI }}
E2E_URL: ${{ env.E2E_URL }}
- name: Run E2E Tests - Playwright for Workflow Dispatch event
if: github.event_dispatch == 'workflow_dispatch'
run: yarn test:e2e
env:
CI: ${{ env.CI }}
E2E_URL: ${{ env.E2E_URL }}
- name: Stop application (for PRs only)
if: always() && github.event_name != 'workflow_dispatch'
run: |
kill $(cat .pidfile)
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
e2e-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js version from .nvmrc
id: nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Start application (for PRs only)
if: github.event_name != 'workflow_dispatch'
run: |
yarn start &
echo $! > .pidfile
- name: Wait for application to be ready (for PRs only)
if: github.event_name != 'workflow_dispatch'
run: |
echo "Waiting for application to start..."
npx wait-on ${{ env.E2E_URL }}
- name: Run E2E Tests - Playwright for PRs
if: github.event_name == 'pull_request'
run: yarn test:e2e:changed
env:
CI: ${{ env.CI }}
E2E_URL: ${{ env.E2E_URL }}
- name: Run E2E Tests - Playwright for Workflow Dispatch event
if: github.event_dispatch == 'workflow_dispatch'
run: yarn test:e2e
env:
CI: ${{ env.CI }}
E2E_URL: ${{ env.E2E_URL }}
- name: Stop application (for PRs only)
if: always() && github.event_name != 'workflow_dispatch'
run: |
kill $(cat .pidfile)
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the release'
required: true
push:
tags:
- '*'
workflow_run:
workflows: ["E2E Tests", "Unit Tests"]
types: [completed]
env:
TAG_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name || github.ref_name }}
jobs:
check-tag:
name: Check Tag
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Check if tag exists
id: check_tag
run: |
git fetch --tags
if git rev-parse "${{ env.tag_name }}" >/dev/null 2>&1; then
echo "Tag already exists. Cancelling the release."
exit 1
create-release:
name: Create Release
runs-on: ubuntu-latest
needs: check-tag
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Create Tag (only for workflow_dispatch)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git tag ${{ env.TAG_NAME }}
git push origin ${{ env.TAG_NAME }}
- name: Set up GitHub CLI
run: |
sudo apt-get install -y gh
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Create Release with GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ env.TAG_NAME }} --title "Release ${{ env.TAG_NAME }}" --notes "Release notes generated automatically." --generate-notes
36 changes: 18 additions & 18 deletions .github/workflows/ut.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Unit Tests - Vitest
name: Unit Tests
on:
workflow_dispatch:
pull_request:
branches: [main]
workflow_dispatch:
pull_request:
branches: [main]
jobs:
ut-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js version from .nvmrc
id: nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Execute Unit tests
run: yarn test:ut
ut-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js version from .nvmrc
id: nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Execute Unit tests
run: yarn test:ut
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
"@fontsource-variable/nunito-sans": "^5.0.16",
"@fontsource/baskervville": "^5.0.22",
"@hookform/resolvers": "^3.9.0",
"@million/lint": "1.0.0-rc.82-beta.50",
"algoliasearch": "^5.3.2",
"@million/lint": "1.0.0-rc.84",
"algoliasearch": "^5.4.0",
"astro": "^4.15.4",
"clsx": "^2.1.1",
"contentful": "^10.15.0",
"contentful": "^10.15.1",
"firebase": "^10.13.1",
"firebase-admin": "^12.4.0",
"gsap": "^3.12.5",
Expand Down
1 change: 0 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import MyWork from "@modules/home/components/myWork/MyWork.astro";
import Testimonials from "@modules/home/components/testimonials/Testimonials.astro";
import Welcome from "@modules/home/components/welcome/Welcome.astro";
// todo: ci for release
// check responsive
// todo: add signature email
// todo: add small transitions & animations
Expand Down
Loading

0 comments on commit 7712ca5

Please sign in to comment.