-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (77 loc) · 2.42 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Run All Tests
on:
pull_request:
branches: [develop, staging]
types: [opened, reopened, synchronize]
workflow_dispatch:
jobs:
info:
name: Gather info for jobs
timeout-minutes: 1
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.target_branch.outputs.branch }}
env_name: ${{ steps.environment.outputs.name }}
steps:
- name: Get target branch
run: |
branch=${{ github.event.pull_request.base.ref }}
echo "branch=${branch}" >> $GITHUB_OUTPUT
echo "::group::Bramch"
echo 'environment: '${branch}
echo "::endgroup::"
id: target_branch
- name: Get environment
run: |
env=dev
if [ "${{ steps.target_branch.outputs.name }}" = "main" ]
then
env=prod
fi
echo "name=${env}" >> $GITHUB_OUTPUT
echo "::group::Environment"
echo 'environment: '${env}
echo "::endgroup::"
id: environment
test:
name: Lint and test
timeout-minutes: 15
runs-on: ubuntu-latest
needs: [info]
environment:
name: ${{ needs.info.outputs.env_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node JS
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION || 'latest' }}
cache: 'yarn'
- name: Install dependencies
run: |
echo "::group::Node version"
echo 'node version requested: ${{ vars.NODE_VERSION || 'latest' }}'
echo 'node version: '$(node --version)
echo "::endgroup::"
version=$(yarn --version)
requested_version=${{ vars.YARN_VERSION || 'latest' }}
yarn set version ${requested_version}
yarn plugin import @yarnpkg/plugin-workspace-tools
echo "::group::Yarn version"
echo 'initial yarn version: '${version}
echo 'yarn version requested: '${requested_version}
echo 'yarn version: '$(yarn --version)
echo "::endgroup::"
yarn
- name: Lint project
run: yarn lint
# TODO: fix playwright tests and add back into gh actions
# - name: Install Playwright
# run: npx playwright install --with-deps
- name: Run Jest
run: yarn test:unit
# - name: Run Playwright tests
# run: yarn test:e2e