Skip to content

Commit

Permalink
add Carryforward Flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nora-codecov committed Sep 13, 2024
1 parent f0344ab commit 7190cc3
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 37 deletions.
85 changes: 50 additions & 35 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
version: 2.1
#version: 2.1
#
#orbs:
# codecov: codecov/codecov@4.0.1
#
#jobs:
# test-api:
# docker:
# - image: cimg/python:3.10.2
# steps:
# - checkout
# - run:
# name: Install requirements
# command: pip install -r api/requirements.txt
# - run:
# name: Run tests and collect coverage
# command: pytest --cov api.calculator
# - codecov/upload:
# flags: backend
#
# test-frontend:
# docker:
# - image: cimg/node:17.6.0
# steps:
# - checkout
# - run:
# name: Install requirements
# command: cd web && npm install
# - run:
# name: Run tests and collect coverage
# command: cd web && npm run test
# - codecov/upload:
# flags: frontend
#
#workflows:
# version: 2.1
# build-test:
# jobs:
# - test-api
# - test-frontend

orbs:
codecov: codecov/codecov@4.0.1

jobs:
test-api:
docker:
- image: cimg/python:3.10.2
steps:
- checkout
- run:
name: Install requirements
command: pip install -r api/requirements.txt
- run:
name: Run tests and collect coverage
command: pytest --cov api.calculator
- codecov/upload:
flags: backend
version: 2.1

test-frontend:
docker:
- image: cimg/node:17.6.0
steps:
- checkout
- run:
name: Install requirements
command: cd web && npm install
- run:
name: Run tests and collect coverage
command: cd web && npm run test
- codecov/upload:
flags: frontend
setup: true

orbs:
path-filtering: circleci/path-filtering@0.1.1

workflows:
version: 2.1
build-test:
jobs:
- test-api
- test-frontend
jobs:
- path-filtering/filter:
mapping: |
api/.* test-api-job true
web/.* test-frontend-job true
47 changes: 47 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: 2.1

orbs:
codecov: codecov/codecov@3.2.2

parameters:
test-api-job:
type: boolean
default: false
test-frontend-job:
type: boolean
default: false

jobs:
test-api:
docker:
- image: cimg/python:3.10.2
name: Install requirements
command: pip install -r api/requirements.txt
- run:
name: Run tests and collect coverage
command: pytest --cov --cov-report xml .
- codecov/upload:
flags: backend
test-frontend:
docker:
- image: cimg/node:17.6.0
steps:
- checkout
- run:
name: Install requirements
command: cd web && npm install
- run:
name: Run tests and collect coverage
command: cd web && npm run test
- codecov/upload:
flags: frontend

workflows:
test-api-workflow:
when: <<pipeline.parameters.test-api-job>>
jobs:
- test-api
test-frontend-workflow:
when: <<pipeline.parameters.test-frontend-job>>
jobs:
- test-frontend
5 changes: 4 additions & 1 deletion .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: API workflow

on: [push, pull_request]
on:
push:
paths:
- 'api/**'

permissions:
id-token: write # This is required for requesting the JWT
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Frontend workflow

on: [push, pull_request]
on:
push:
paths:
- 'web/**'

permissions:
id-token: write # This is required for requesting the JWT
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ coverage:
patch: off

flag_management:
default_rules:
carryforward: true
individual_flags:
- name: backend
paths:
Expand Down
19 changes: 19 additions & 0 deletions web/static/js/calculator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,23 @@ describe('Calculator test suite', () => {
calculator.delete();
expect(calculator.currentOperand).toBe('1');
})

test('test operation', () => {
const calculator = new calc.Calculator();
calculator.chooseOperation('+');
expect(calculator.operation).toBeUndefined();

calculator.appendNumber(1);
calculator.appendNumber(2);
calculator.chooseOperation('+');
expect(calculator.currentOperand).toBe('');
expect(calculator.operation).toBe('+');
expect(calculator.previousOperand).toBe('12');

calculator.appendNumber(3);
calculator.appendNumber(4);
expect(calculator.currentOperand).toBe('34');
expect(calculator.operation).toBe('+');
expect(calculator.previousOperand).toBe('12');
})
})

0 comments on commit 7190cc3

Please sign in to comment.