From bc0b0a26c99da86c6a1361c2a1d73b3529aa17c9 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 10:56:58 -0600 Subject: [PATCH 1/7] Initial GitHub Actions CI settings. Rename docker-compose-travis to docker-compose-ci --- .github/workflows/build.yml | 80 +++++++++++++++++++ ...mpose-travis.yml => docker-compose-ci.yml} | 1 + 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/build.yml rename docker/{docker-compose-travis.yml => docker-compose-ci.yml} (94%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..41986cf2f3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,80 @@ +# DSpace Continuous Integration/Build via GitHub Actions +# Concepts borrowed from +# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs +name: Build + +# Run this Build only for pushes / PRs to main branch +on: [push, pull_request] +# push: +# branches: main +# pull_request: +# branches: main + +jobs: + build: + runs-on: ubuntu-latest + env: + # The ci step will test the dspace-angular code against DSpace REST. + # Direct that step to utilize a DSpace REST service that has been started in docker. + DSPACE_REST_HOST: localhost + DSPACE_REST_PORT: 8080 + DSPACE_REST_NAMESPACE: '/server' + DSPACE_REST_SSL: false + strategy: + # Create a matrix of Node versions to test against (in parallel) + matrix: + node-version: [10.x, 12.x] + # Do NOT exit immediately if one matrix job fails + fail-fast: false + # These are the actual CI steps to perform per job + steps: + # https://github.com/actions/checkout + - name: Checkout codebase + uses: actions/checkout@v2 + # https://github.com/actions/setup-node + - name: Install Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install latest Chrome (for e2e tests) + run: | + sudo apt-get update + sudo apt-get --only-upgrade install google-chrome-stable -y + google-chrome --version + # https://github.com/actions/cache/blob/main/examples.md#node---yarn + - name: Get Yarn cache directory + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Cache Yarn dependencies + uses: actions/cache@v2 + with: + # Cache entire Yarn cache directory (see previous step) + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + # Cache key is hash of yarn.lock. Therefore changes to yarn.lock will invalidate cache + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: ${{ runner.os }}-yarn- + - name: Install Yarn dependencies + run: yarn install --frozen-lockfile + - name: Run lint + run: yarn run lint + - name: Run build + run: yarn run build:prod + - name: Run specs (unit tests) + run: yarn run test:headless + # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 + # Upload coverage reports to Codecov (for Node v12 only) + # https://github.com/codecov/codecov-action + - name: Upload coverage to Codecov.io + uses: codecov/codecov-action@v1 + if: matrix.node-version == '12.x' + # Using docker-compose start backend using CI configuration + # and load assetstore from a cached copy + - name: Start DSpace REST Backend via Docker (for e2e tests) + run: | + docker-compose -f ./docker/docker-compose-ci.yml up -d + docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli + docker container ls + - name: Run e2e tests (integration tests) + run: yarn run e2e:ci + - name: Shutdown Docker containers + run: docker-compose -f ./docker/docker-compose-ci.yml down diff --git a/docker/docker-compose-travis.yml b/docker/docker-compose-ci.yml similarity index 94% rename from docker/docker-compose-travis.yml rename to docker/docker-compose-ci.yml index f0f5ef70e8..f440454bb6 100644 --- a/docker/docker-compose-travis.yml +++ b/docker/docker-compose-ci.yml @@ -1,3 +1,4 @@ +# Docker Compose for running the DSpace backend for e2e testing in CI networks: dspacenet: services: From 8d526f0e80f7e717d79e75a3a74ff54994ee998b Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 16:03:22 -0600 Subject: [PATCH 2/7] Move codecov reports to last step --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41986cf2f3..d57c941a58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,12 +61,6 @@ jobs: run: yarn run build:prod - name: Run specs (unit tests) run: yarn run test:headless - # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 - # Upload coverage reports to Codecov (for Node v12 only) - # https://github.com/codecov/codecov-action - - name: Upload coverage to Codecov.io - uses: codecov/codecov-action@v1 - if: matrix.node-version == '12.x' # Using docker-compose start backend using CI configuration # and load assetstore from a cached copy - name: Start DSpace REST Backend via Docker (for e2e tests) @@ -78,3 +72,9 @@ jobs: run: yarn run e2e:ci - name: Shutdown Docker containers run: docker-compose -f ./docker/docker-compose-ci.yml down + # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 + # Upload coverage reports to Codecov (for Node v12 only) + # https://github.com/codecov/codecov-action + - name: Upload coverage to Codecov.io + uses: codecov/codecov-action@v1 + if: matrix.node-version == '12.x' From b036c084b71a10423aadca4a3decb888cdc51078 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 16:38:07 -0600 Subject: [PATCH 3/7] Try codecov bash uploader to see if it works --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d57c941a58..e4ede2aecc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,5 +76,6 @@ jobs: # Upload coverage reports to Codecov (for Node v12 only) # https://github.com/codecov/codecov-action - name: Upload coverage to Codecov.io - uses: codecov/codecov-action@v1 + #uses: codecov/codecov-action@v1 + run: bash <(curl -s https://codecov.io/bash) if: matrix.node-version == '12.x' From e32b435edd5057fb9300d066e7c6f44bc94664df Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 17:07:49 -0600 Subject: [PATCH 4/7] Remove .travis.yml Minor comment cleanup to build.yml --- .github/workflows/build.yml | 2 -- .travis.yml | 66 ------------------------------------- 2 files changed, 68 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4ede2aecc..7b6bd26e3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,8 +74,6 @@ jobs: run: docker-compose -f ./docker/docker-compose-ci.yml down # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 # Upload coverage reports to Codecov (for Node v12 only) - # https://github.com/codecov/codecov-action - name: Upload coverage to Codecov.io - #uses: codecov/codecov-action@v1 run: bash <(curl -s https://codecov.io/bash) if: matrix.node-version == '12.x' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index db3b49ccdf..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,66 +0,0 @@ -os: linux -dist: bionic -language: node_js - -# Enable caching for yarn & node_modules -cache: - yarn: true - -node_js: - - "10" - - "12" - -# Install latest chrome (for e2e headless testing). Run an update if needed. -addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable - update: true - -env: - # The ci step will test the dspace-angular code against DSpace REST. - # Direct that step to utilize a DSpace REST service that has been started in docker. - DSPACE_REST_HOST: localhost - DSPACE_REST_PORT: 8080 - DSPACE_REST_NAMESPACE: '/server' - DSPACE_REST_SSL: false - -before_install: - # Check our versions of everything - - echo "Check versions" - - yarn -v - - docker-compose -v - - google-chrome-stable --version - -install: - # Start up a test DSpace 7 REST backend using the entities database dump - - docker-compose -f ./docker/docker-compose-travis.yml up -d - # Use the dspace-cli image to populate the assetstore. Triggers a discovery and oai update - - docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli - # Install all local dependencies (retry if initially fails) - - travis_retry yarn install - -before_script: - - echo "Check Docker containers" - - docker container ls - # The following line could be enabled to verify that the rest server is responding. - #- echo "Check REST API available (via Docker)" - #- curl http://localhost:8080/server/ - -script: - # build app and run all tests - - ng lint || travis_terminate 1; - - travis_wait yarn run build:prod || travis_terminate 1; - - yarn test:headless || travis_terminate 1; - - yarn run e2e:ci || travis_terminate 1; - -after_script: - # Shutdown docker after everything runs - - docker-compose -f ./docker/docker-compose-travis.yml down - -# After a successful build and test (see 'script'), send code coverage reports to codecov.io -# NOTE: As there's no need to send coverage multiple times, we only run this for one version of node. -after_success: - - if [ "$TRAVIS_NODE_VERSION" = "12" ]; then bash <(curl -s https://codecov.io/bash); fi From d241d4ea6a5948fd917c2fc8859f8d2d7cae5344 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 25 Nov 2020 08:27:25 -0600 Subject: [PATCH 5/7] Revert to checkout@v1 per https://community.codecov.io/t/codecov-status-stuck-at-waiting-for-status-to-be-reported-on-github/341/40 --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b6bd26e3a..6f5f56584f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: steps: # https://github.com/actions/checkout - name: Checkout codebase - uses: actions/checkout@v2 + uses: actions/checkout@v1 # https://github.com/actions/setup-node - name: Install Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 @@ -74,6 +74,7 @@ jobs: run: docker-compose -f ./docker/docker-compose-ci.yml down # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 # Upload coverage reports to Codecov (for Node v12 only) + # https://github.com/codecov/codecov-action - name: Upload coverage to Codecov.io - run: bash <(curl -s https://codecov.io/bash) + uses: codecov/codecov-action@v1 if: matrix.node-version == '12.x' From 49effd14dfbd470f5e267d0e95d1470cc1c44a4f Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 25 Nov 2020 08:58:38 -0600 Subject: [PATCH 6/7] Rename job to "tests". Space out steps to make it easier to read. --- .github/workflows/build.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f5f56584f..3894b445ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: [push, pull_request] # branches: main jobs: - build: + tests: runs-on: ubuntu-latest env: # The ci step will test the dspace-angular code against DSpace REST. @@ -31,16 +31,19 @@ jobs: # https://github.com/actions/checkout - name: Checkout codebase uses: actions/checkout@v1 + # https://github.com/actions/setup-node - name: Install Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + - name: Install latest Chrome (for e2e tests) run: | sudo apt-get update sudo apt-get --only-upgrade install google-chrome-stable -y google-chrome --version + # https://github.com/actions/cache/blob/main/examples.md#node---yarn - name: Get Yarn cache directory id: yarn-cache-dir-path @@ -53,14 +56,19 @@ jobs: # Cache key is hash of yarn.lock. Therefore changes to yarn.lock will invalidate cache key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: ${{ runner.os }}-yarn- + - name: Install Yarn dependencies run: yarn install --frozen-lockfile + - name: Run lint run: yarn run lint + - name: Run build run: yarn run build:prod + - name: Run specs (unit tests) run: yarn run test:headless + # Using docker-compose start backend using CI configuration # and load assetstore from a cached copy - name: Start DSpace REST Backend via Docker (for e2e tests) @@ -68,10 +76,13 @@ jobs: docker-compose -f ./docker/docker-compose-ci.yml up -d docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli docker container ls + - name: Run e2e tests (integration tests) run: yarn run e2e:ci + - name: Shutdown Docker containers run: docker-compose -f ./docker/docker-compose-ci.yml down + # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 # Upload coverage reports to Codecov (for Node v12 only) # https://github.com/codecov/codecov-action From 3f1266e485aad7d4d86697e719117292ed7c17cd Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 25 Nov 2020 09:26:43 -0600 Subject: [PATCH 7/7] Enable only for main branch pushes or PRs --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3894b445ac..23fd346953 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,11 +4,11 @@ name: Build # Run this Build only for pushes / PRs to main branch -on: [push, pull_request] -# push: -# branches: main -# pull_request: -# branches: main +on: + push: + branches: main + pull_request: + branches: main jobs: tests: