diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..c305c4b --- /dev/null +++ b/.github/workflows/cd.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..303220e --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/ci2.yml b/.github/workflows/ci2.yml new file mode 100644 index 0000000..7fd493f --- /dev/null +++ b/.github/workflows/ci2.yml @@ -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 diff --git a/src/calculator.test.ts b/src/calculator.test.ts index efea4b6..04868ef 100644 --- a/src/calculator.test.ts +++ b/src/calculator.test.ts @@ -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', () => {