Skip to content
Open
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
44 changes: 44 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/cd.yml
name: Deploying to Github Pages
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Fetch repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: |
yarn
- name: Building
run: |
NODE_ENV=production yarn build
- name: Uploading production artifacts
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: dist

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Publishing production artifact
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: github-pages
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .github/workflows/ci.yml
name: CI/CD Pipeline
# this workflow will run when there is a pull req (when will it run?)
on: [pull_request, workflow_dispatch]
# jobs are vms that run your behaviour
jobs:
unit-tests: # id -> let us refer to job itself
runs-on: ubuntu-latest
steps:
# fetch repo that person made the pull req
- name: Fetch repository
uses: actions/checkout@v4
# Install nodejs
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn' # stick to yarn log file
# Install proj dependencies
- name: Install dependencies
# Run set of commands within vm
run: |
yarn
# Run
- name: Run unit tests
run: |
NODE_ENV=production yarn test
37 changes: 37 additions & 0 deletions .github/workflows/ci2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# .github/workflows/ci.yml
name: CI/CD Pipeline
on: [pull_request, workflow_dispatch]
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Fetch repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: |
yarn
- name: Lint code
run: |
yarn lint

unit-tests:
runs-on: ubuntu-latest
steps:
- name: Fetch repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install dependencies
run: |
yarn
- name: Run unit tests
run: |
NODE_ENV=production yarn test
2 changes: 1 addition & 1 deletion src/calculator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('subtract 1 + 2 to equal -1', () => {
});

test('divide 1 / 2 to equal 0.5', () => {
expect(divide(1, 2)).toBe(0.4);
expect(divide(1, 2)).toBe(0.5);
});

test('multiply 1 * 2 to equal 2', () => {
Expand Down