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

Adding tests #2

Merged
merged 18 commits into from
Apr 19, 2023
62 changes: 62 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: E2E Tests

on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- edited
- synchronize

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
ghc: ['8.8.4']
spec:
- '0.16.1'
node:
- 16

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: npm ci

- name: Install dfx
run: echo y | sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

- name: Start dfx
run: dfx start --background --clean

- name: Deploy test canister
run: dfx deploy test

- name: Run e2e tests
run: npm run test:e2e

- name: Clean Up
run: killall dfx replica

aggregate:
name: e2e:required
if: ${{ always() }}
needs: [test]
runs-on: ubuntu-latest
steps:
- name: check e2e test result
if: ${{ needs.test.result != 'success' }}
run: exit 1
39 changes: 39 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Check Formatting
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ghc: ['8.8.4']
spec:
- release-0.16 # https://github.com/dfinity-lab/ic-ref/tree/release-0.16
node:
- 14
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install -g npm
- run: npm install prettier pretty-quick
- run: npm run prettier:check

aggregate:
name: format:required
if: ${{ always() }}
needs: [test]
runs-on: ubuntu-latest
steps:
- name: check e2e test result
if: ${{ needs.test.result != 'success' }}
run: exit 1
56 changes: 56 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Unit Tests

on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- edited
- synchronize

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
ghc: ['8.8.4']
spec:
- '0.16.1'
node:
- 16

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: npm ci

- name: Install dfx
run: echo y | sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

- name: Start dfx
run: dfx start --background --clean

- name: Run unit tests
run: npm run test

aggregate:
name: unit:required
if: ${{ always() }}
needs: [test]
runs-on: ubuntu-latest
steps:
- name: check unit test result
if: ${{ needs.test.result != 'success' }}
run: exit 1
6 changes: 5 additions & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
"demo": {
"type": "motoko",
"main": "examples/demo/demo.mo"
},
"test": {
"type": "motoko",
"main": "examples/test/test.mo"
}
},
"defaults": {
"build": {
"packtool": "npx mops sources"
"packtool": "npm run --silent sources"
}
}
}
Binary file added examples/test/assets/icon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/test/assets/profile.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading