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

Add GitHub Actions Workflow #25

Merged
merged 6 commits into from
Dec 14, 2024
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
30 changes: 30 additions & 0 deletions .github/actions/cached-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Get & Cache Dependencies"
description: "Get the dependencies (via npm) and cache them for later use."
inputs:
caching:
description: "Whether to cache the dependencies or not."
required: false
default: "true"
outputs:
used-cache:
description: "Whether the cache was used or not."
value: ${{ steps.set-output.outputs.used-cache }}
runs:
using: "composite"
steps:
- name: Cache dependencies
uses: actions/cache@v4
if: inputs.caching == 'true'
id: cache
with:
path: node_modules
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
id: install
if: steps.cache.outputs.cache-hit != 'true' || inputs.caching != 'true'
shell: bash
run: npm ci
- name: Set output
id: set-output
shell: bash
run: echo "used-cache='${{ steps.cache.outputs.cache-hit }}'" >> $GITHUB_OUTPUT
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test and Build the Application
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
- name: Run the linter
run: npm run lint -- --max-warnings=0
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
- name: Run tests
run: npm test
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.11.1"
- name: Load & cache dependencies
uses: ./.github/actions/cached-deps
id: chached-deps
- name: Build the application
run: npm run build
- name: Upload artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: dist-files
path: dist
report:
runs-on: ubuntu-latest
needs: [lint, build]
if: failure()
steps:
- name: Output information
run: |
echo "Something went wrong!"
echo "${{ toJson(github)}}"
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"material-icon-theme.files.associations": {
".tool-versions": "nodejs_alt"
},
"material-icon-theme.folders.associations": {
"actions": "gh-workflows",
"cached-deps": "temp"
},
"tailwindCSS.experimental.classRegex": [
["[cC]lasses\\s*\\+?=\\s*([^;]*);", "'([^']*)'"],
["[cC]lasses\\s*\\+?=\\s*([^;]*);", "\"([^\"]*)\""],
Expand Down
3 changes: 3 additions & 0 deletions src/pages/AuthenticationPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { render, screen } from "@testing-library/react";

import AuthenticationPage from "./AuthenticationPage";

vi.mock("firebase/auth");
vi.mock("@/utils/firebase");

test("should render the sign in form", function () {
render(<AuthenticationPage />);
expect(screen.getByRole("heading", { name: /sign in/i })).toBeInTheDocument();
Expand Down
Loading