Skip to content

Commit

Permalink
test: enable coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Sep 25, 2024
1 parent e2cbc56 commit c10b6ca
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 14 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
Expand Down Expand Up @@ -97,7 +100,9 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
coveralls.io:443
dl.google.com:443
objects.githubusercontent.com:443
github.com:443
registry.npmjs.org:443
Expand All @@ -116,12 +121,13 @@ jobs:
run: npm ci

- name: Run tests
run: |
npm exec \
--no \
--package=jest \
-- \
jest
run: npm test

- name: Publish Coverage Report
uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage/lcov.info

android-build:
name: Android Build
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage/
node_modules/
.lsp/
*~
Expand All @@ -15,8 +16,6 @@ npm-debug.*
web-build/
android/
ios/
assets/*
!assets/**/*.svg
# macOS
.DS_Store

Expand Down
12 changes: 10 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ Due to the proprietary license and size of assets, they are stored in a separate

**Do not introduce local changes directly to the git submodule. Instead, merge the changes to the original `safsbe/mental-health-app-assets` Git repository's `main` branch and follow the steps below to update the reference in this Git repository.**

After merging changes into the `main` branch of `safsbe/mental-health-app-assets`, run `git submodule update assets/` in the root of **this** repository.
After merging changes into the `main` branch of `safsbe/mental-health-app-assets`, run the following in the root of **this** repository:

You must `git commit` after a `git submodule update`.
```sh
$ git submodule update --remote assets/
```

You must `git commit` after a `git submodule update --remote`.

### Writing a commit

Expand All @@ -77,3 +81,7 @@ Ensure that:

- `user.email` in your `~/.gitconfig` is an email tied to your Github account (Github's masked emails **are** accepted).
- The email in at least one `Signed-off-by` line in each commit matches the email of the Git Committer or Git Author of that commit.

### `Error: Unable to resolve module` or `None of these files exist` in CI pipeline

You may have added new assets into the `assets/` subdirectory. Ensure that these new assets have been merged into the `main` branch of the `mental-health-app-assets` Git repository.
51 changes: 51 additions & 0 deletions app/calendar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import moment from 'moment';
import {Text, View} from 'react-native';

export type CalendarProps = {
view: 'week' | 'month';
activeWeekOrMonth?: number;
activeYear?: number;
selectedDate: Date;
};

export function Calendar({
view,
activeWeekOrMonth,
activeYear,
selectedDate,
}: CalendarProps) {
function isLeapYear(year: number) {
if (year % 4 !== 0) return false;
if (year % 100 === 0 && year % 400 !== 0) return false;
return true;
}

const activeMonth = selectedDate.getUTCMonth();
activeYear = selectedDate.getUTCFullYear();
const activeMonthStartDay = selectedDate.getDay();

Check warning on line 25 in app/calendar/index.tsx

View workflow job for this annotation

GitHub Actions / Code Lint

'activeMonthStartDay' is assigned a value but never used

const monthDayCount = [

Check warning on line 27 in app/calendar/index.tsx

View workflow job for this annotation

GitHub Actions / Code Lint

'monthDayCount' is assigned a value but never used
31,
(() => (isLeapYear(activeYear) ? 29 : 28))(),
31,
30,
31,
30,
31,
31,
30,
31,
30,
31,
];

const monthStartDay = activeMonth;

Check warning on line 42 in app/calendar/index.tsx

View workflow job for this annotation

GitHub Actions / Code Lint

'monthStartDay' is assigned a value but never used

return (
<View>
<Text>{moment('MMMM')}</Text>
</View>
);
}

export default function CalendarWrapper() {}
9 changes: 9 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"preset": "jest-expo",
"collectCoverage": true,
"collectCoverageFrom": [
"components/**",
"!components/__tests__/**",
"app/**"
]
}
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
"test:watch": "jest --watchAll",
"eslint": "eslint .",
"eslint:fix": "npm run eslint -- --fix",
"prettier:cli": "prettier '**/*.md' '**/*.ts' '**/*.tsx' '**/*.js' '**/*.mjs'",
"prettier:cli": "prettier '**/*.md' '**/*.ts' '**/*.tsx' '**/*.js' '**/*.mjs' '!assets/**'",
"prettier:check": "npm run prettier:cli -- --check",
"prettier:fix": "npm run prettier:cli -- --write",
"lint:check": "npm run eslint && npm run prettier:check",
"lint:fix": "npm run eslint:fix && npm run prettier:fix"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo-google-fonts/mulish": "^0.2.3",
"@expo/vector-icons": "^14.0.3",
Expand Down

0 comments on commit c10b6ca

Please sign in to comment.