Commits
Tim Donohue authored bc0b0a26c99
1 + | # DSpace Continuous Integration/Build via GitHub Actions |
2 + | # Concepts borrowed from |
3 + | # https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs |
4 + | name Build |
5 + | |
6 + | # Run this Build only for pushes / PRs to main branch |
7 + | on push pull_request |
8 + | # push: |
9 + | # branches: main |
10 + | # pull_request: |
11 + | # branches: main |
12 + | |
13 + | jobs |
14 + | build |
15 + | runs-on ubuntu-latest |
16 + | env |
17 + | # The ci step will test the dspace-angular code against DSpace REST. |
18 + | # Direct that step to utilize a DSpace REST service that has been started in docker. |
19 + | DSPACE_REST_HOST localhost |
20 + | DSPACE_REST_PORT 8080 |
21 + | DSPACE_REST_NAMESPACE '/server' |
22 + | DSPACE_REST_SSL false |
23 + | strategy |
24 + | # Create a matrix of Node versions to test against (in parallel) |
25 + | matrix |
26 + | node-version 10.x 12.x |
27 + | # Do NOT exit immediately if one matrix job fails |
28 + | fail-fast false |
29 + | # These are the actual CI steps to perform per job |
30 + | steps |
31 + | # https://github.com/actions/checkout |
32 + | name Checkout codebase |
33 + | uses actions/checkout@v2 |
34 + | # https://github.com/actions/setup-node |
35 + | name Install Node.js $ matrix.node-version |
36 + | uses actions/setup-node@v1 |
37 + | with |
38 + | node-version $ matrix.node-version |
39 + | name Install latest Chrome (for e2e tests) |
40 + | run |
41 + | sudo apt-get update |
42 + | sudo apt-get --only-upgrade install google-chrome-stable -y |
43 + | google-chrome --version |
44 + | # https://github.com/actions/cache/blob/main/examples.md#node---yarn |
45 + | name Get Yarn cache directory |
46 + | id yarn-cache-dir-path |
47 + | run echo "::set-output name=dir::$(yarn cache dir)" |
48 + | name Cache Yarn dependencies |
49 + | uses actions/cache@v2 |
50 + | with |
51 + | # Cache entire Yarn cache directory (see previous step) |
52 + | path $ steps.yarn-cache-dir-path.outputs.dir |
53 + | # Cache key is hash of yarn.lock. Therefore changes to yarn.lock will invalidate cache |
54 + | key $ runner.os -yarn-$ hashFiles('**/yarn.lock') |
55 + | restore-keys $ runner.os -yarn- |
56 + | name Install Yarn dependencies |
57 + | run yarn install --frozen-lockfile |
58 + | name Run lint |
59 + | run yarn run lint |
60 + | name Run build |
61 + | run yarn run build prod |
62 + | name Run specs (unit tests) |
63 + | run yarn run test headless |
64 + | # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 |
65 + | # Upload coverage reports to Codecov (for Node v12 only) |
66 + | # https://github.com/codecov/codecov-action |
67 + | name Upload coverage to Codecov.io |
68 + | uses codecov/codecov-action@v1 |
69 + | if matrix.node-version == '12.x' |
70 + | # Using docker-compose start backend using CI configuration |
71 + | # and load assetstore from a cached copy |
72 + | name Start DSpace REST Backend via Docker (for e2e tests) |
73 + | run |
74 + | docker-compose -f ./docker/docker-compose-ci.yml up -d |
75 + | docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli |
76 + | docker container ls |
77 + | name Run e2e tests (integration tests) |
78 + | run yarn run e2e ci |
79 + | name Shutdown Docker containers |
80 + | run docker-compose -f ./docker/docker-compose-ci.yml down |