Skip to content

Commit 7b4c80a

Browse files
Merged dspace-cris-2024_02_x into task/dspace-cris-2024_02_x/DSC-1956
2 parents 13ca8eb + ede79e3 commit 7b4c80a

271 files changed

Lines changed: 6879 additions & 2735 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
# Spin up UI on 127.0.0.1 to avoid host resolution issues in e2e tests with Node 18+
2525
DSPACE_UI_HOST: 127.0.0.1
2626
DSPACE_UI_PORT: 4000
27+
DSPACE_UI_BASEURL: http://127.0.0.1:4000
2728
# Ensure all SSR caching is disabled in test environment
2829
DSPACE_CACHE_SERVERSIDE_BOTCACHE_MAX: 0
2930
DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX: 0
@@ -39,8 +40,11 @@ jobs:
3940
# Project name to use when running "docker compose" prior to e2e tests
4041
COMPOSE_PROJECT_NAME: 'ci'
4142
# Docker Registry to use for Docker compose scripts below.
42-
# We use GitHub's Container Registry to avoid aggressive rate limits at DockerHub.
43-
DOCKER_REGISTRY: ghcr.io
43+
# On the upstream dspace/dspace-angular repository we use GitHub's Container Registry
44+
# (ghcr.io) to avoid aggressive rate limits at DockerHub. Forks cannot authenticate
45+
# against ghcr.io/dspace/* with their own GITHUB_TOKEN (and the images there require
46+
# auth), so on forks we fall back to docker.io where the same images are public.
47+
DOCKER_REGISTRY: ${{ github.repository == 'dspace/dspace-angular' && 'ghcr.io' || 'docker.io' }}
4448
strategy:
4549
# Create a matrix of Node versions to test against (in parallel)
4650
matrix:
@@ -51,11 +55,11 @@ jobs:
5155
steps:
5256
# https://github.com/actions/checkout
5357
- name: Checkout codebase
54-
uses: actions/checkout@v4
58+
uses: actions/checkout@v6
5559

5660
# https://github.com/actions/setup-node
5761
- name: Install Node.js ${{ matrix.node-version }}
58-
uses: actions/setup-node@v4
62+
uses: actions/setup-node@v6
5963
with:
6064
node-version: ${{ matrix.node-version }}
6165

@@ -80,7 +84,7 @@ jobs:
8084
id: yarn-cache-dir-path
8185
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
8286
- name: Cache Yarn dependencies
83-
uses: actions/cache@v4
87+
uses: actions/cache@v5
8488
with:
8589
# Cache entire Yarn cache directory (see previous step)
8690
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -113,16 +117,21 @@ jobs:
113117
# so that it can be shared with the 'codecov' job (see below)
114118
# NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286
115119
- name: Upload code coverage report to Artifact
116-
uses: actions/upload-artifact@v4
120+
uses: actions/upload-artifact@v7
117121
if: matrix.node-version == '18.x'
118122
with:
119123
name: coverage-report-${{ matrix.node-version }}
120124
path: 'coverage/dspace-angular/lcov.info'
121125
retention-days: 14
122126

123-
# Login to our Docker registry, so that we can access private Docker images using "docker compose" below.
127+
# Login to our Docker registry, so that we can access Docker images using "docker compose" below.
128+
# This login is required on the upstream repository because DOCKER_REGISTRY is set to ghcr.io
129+
# and pulling ghcr.io/dspace/* requires authentication. On forks, DOCKER_REGISTRY falls back to
130+
# docker.io (see env block above) where the same images are publicly pullable without a login,
131+
# and forks cannot authenticate against ghcr.io/dspace/* with their own GITHUB_TOKEN anyway.
124132
- name: Login to ${{ env.DOCKER_REGISTRY }}
125-
uses: docker/login-action@v3
133+
uses: docker/login-action@v4
134+
if: github.repository == 'dspace/dspace-angular'
126135
with:
127136
registry: ${{ env.DOCKER_REGISTRY }}
128137
username: ${{ github.repository_owner }}
@@ -139,7 +148,7 @@ jobs:
139148
# https://github.com/cypress-io/github-action
140149
# (NOTE: to run these e2e tests locally, just use 'ng e2e')
141150
- name: Run e2e tests (integration tests)
142-
uses: cypress-io/github-action@v6
151+
uses: cypress-io/github-action@v7.1.9
143152
with:
144153
# Run tests in Chrome, headless mode (default)
145154
browser: chrome
@@ -154,7 +163,7 @@ jobs:
154163
# Cypress always creates a video of all e2e tests (whether they succeeded or failed)
155164
# Save those in an Artifact
156165
- name: Upload e2e test videos to Artifacts
157-
uses: actions/upload-artifact@v4
166+
uses: actions/upload-artifact@v7
158167
if: always()
159168
with:
160169
name: e2e-test-videos-${{ matrix.node-version }}
@@ -163,7 +172,7 @@ jobs:
163172
# If e2e tests fail, Cypress creates a screenshot of what happened
164173
# Save those in an Artifact
165174
- name: Upload e2e test failure screenshots to Artifacts
166-
uses: actions/upload-artifact@v4
175+
uses: actions/upload-artifact@v7
167176
if: failure()
168177
with:
169178
name: e2e-test-screenshots-${{ matrix.node-version }}
@@ -306,22 +315,25 @@ jobs:
306315
codecov:
307316
# Must run after 'tests' job above
308317
needs: tests
318+
# Only run on the upstream repository: forks do not have the CODECOV_TOKEN secret,
319+
# and Codecov refuses to create a commit on a protected branch without a token.
320+
if: github.repository == 'dspace/dspace-angular'
309321
runs-on: ubuntu-latest
310322
steps:
311323
- name: Checkout
312-
uses: actions/checkout@v4
324+
uses: actions/checkout@v6
313325

314326
# Download artifacts from previous 'tests' job
315327
- name: Download coverage artifacts
316-
uses: actions/download-artifact@v4
328+
uses: actions/download-artifact@v8
317329

318330
# Now attempt upload to Codecov using its action.
319331
# NOTE: We use a retry action to retry the Codecov upload if it fails the first time.
320332
#
321333
# Retry action: https://github.com/marketplace/actions/retry-action
322334
# Codecov action: https://github.com/codecov/codecov-action
323335
- name: Upload coverage to Codecov.io
324-
uses: Wandalen/wretry.action@v1.3.0
336+
uses: Wandalen/wretry.action@v3.8.0
325337
with:
326338
action: codecov/codecov-action@v4
327339
# Ensure codecov-action throws an error when it fails to upload

.github/workflows/codescan.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ jobs:
3535
steps:
3636
# https://github.com/actions/checkout
3737
- name: Checkout repository
38-
uses: actions/checkout@v4
38+
uses: actions/checkout@v6
3939

4040
# Initializes the CodeQL tools for scanning.
4141
# https://github.com/github/codeql-action
4242
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v2
43+
uses: github/codeql-action/init@v4
4444
with:
4545
languages: javascript
4646

4747
# Autobuild attempts to build any compiled languages
4848
- name: Autobuild
49-
uses: github/codeql-action/autobuild@v2
49+
uses: github/codeql-action/autobuild@v4
5050

5151
# Perform GitHub Code Scanning.
5252
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@v2
53+
uses: github/codeql-action/analyze@v4

.github/workflows/docker.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,122 @@ jobs:
8080
# these sites as specified in reusable-docker-build.xml
8181
REDEPLOY_SANDBOX_URL: ${{ secrets.REDEPLOY_SANDBOX_URL }}
8282
REDEPLOY_DEMO_URL: ${{ secrets.REDEPLOY_DEMO_URL }}
83+
84+
#################################################################################
85+
# Test Deployment via Docker to ensure newly built images are working properly
86+
#################################################################################
87+
docker-deploy:
88+
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
89+
if: github.repository == 'dspace/dspace-angular'
90+
runs-on: ubuntu-latest
91+
# Must run after all major images are built
92+
needs: [dspace-angular, dspace-angular-dist]
93+
env:
94+
# Override default dspace.server.url & REST 'host' because backend starts at http://127.0.0.1:8080
95+
dspace__P__server__P__url: http://127.0.0.1:8080/server
96+
DSPACE_REST_HOST: 127.0.0.1
97+
# Override default dspace.ui.url to also use 127.0.0.1.
98+
dspace__P__ui__P__url: http://127.0.0.1:4000
99+
# Override default ui.baseUrl to also use 127.0.0.1. This should match 'dspace.ui.url'.
100+
DSPACE_UI_BASEURL: http://127.0.0.1:4000
101+
steps:
102+
# Checkout our codebase (to get access to Docker Compose scripts)
103+
- name: Checkout codebase
104+
uses: actions/checkout@v6
105+
# Download Docker image artifacts (which were just built by reusable-docker-build.yml)
106+
- name: Download Docker image artifacts
107+
uses: actions/download-artifact@v8
108+
with:
109+
# Download all amd64 Docker images (TAR files) into the /tmp/docker directory
110+
pattern: docker-image-*-linux-amd64
111+
path: /tmp/docker
112+
merge-multiple: true
113+
# Load each of the images into Docker by calling "docker image load" for each.
114+
# This ensures we are using the images just built & not any prior versions on DockerHub
115+
- name: Load all downloaded Docker images
116+
run: |
117+
find /tmp/docker -type f -name "*.tar" -exec docker image load --input "{}" \;
118+
docker image ls -a
119+
# Start backend using our compose script in the codebase.
120+
- name: Start backend in Docker
121+
# MUST use docker.io as we don't have a copy of this backend image in our GitHub Action,
122+
# and docker.io is the only public image. If we ever hit aggressive rate limits at DockerHub,
123+
# we may need to consider making the 'ghcr.io' images public & switch this to 'ghcr.io'
124+
env:
125+
DOCKER_REGISTRY: docker.io
126+
run: |
127+
docker compose -f docker/docker-compose-rest.yml up -d
128+
sleep 10
129+
docker container ls
130+
# Create a test admin account. Load test data from a simple set of AIPs as defined in cli.ingest.yml
131+
# NOTE: Before creating test data, we wait for the backend to become responsive by requesting it every 10 sec.
132+
# Timeout after 5 minutes. This is done to ensure the backend is fully initialized before we create test data.
133+
- name: Load test data into Backend
134+
run: |
135+
timeout 5m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:8080/server/api
136+
docker compose -f docker/cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
137+
docker compose -f docker/cli.yml -f docker/cli.ingest.yml run --rm dspace-cli
138+
# Verify backend started successfully.
139+
# 1. Make sure root endpoint is responding (check for dspace.name defined in docker-compose.yml)
140+
# 2. Also check /collections endpoint to ensure the test data loaded properly (check for a collection name in AIPs)
141+
- name: Verify backend is responding properly
142+
run: |
143+
result=$(wget -O- -q http://127.0.0.1:8080/server/api)
144+
echo "$result"
145+
echo "$result" | grep -oE "\"DSpace Started with Docker Compose\""
146+
result=$(wget -O- -q http://127.0.0.1:8080/server/api/core/collections)
147+
echo "$result"
148+
echo "$result" | grep -oE "\"Dog in Yard\""
149+
# Start production frontend using our compose script in the codebase.
150+
- name: Start production frontend in Docker
151+
# Specify the GHCR copy of the production frontend, so that we use the newly built image
152+
env:
153+
DOCKER_REGISTRY: ghcr.io
154+
run: |
155+
docker compose -f docker/docker-compose-dist.yml up -d
156+
sleep 10
157+
docker container ls
158+
# Verify production frontend started successfully.
159+
# 1. Make sure /home path has "DSpace software" (this is in the footer of the page)
160+
# 2. Also check /community-list page lists one of the test Communities in the loaded test data
161+
- name: Verify production frontend is responding properly
162+
run: |
163+
result=$(wget -O- -q http://127.0.0.1:4000/home)
164+
echo "$result"
165+
echo "$result" | grep -oE "\"DSpace software\""
166+
- name: Error logs of production frontend (if error in startup)
167+
if: ${{ failure() }}
168+
run: |
169+
docker compose -f docker/docker-compose-dist.yml logs
170+
# Now shutdown the production frontend image and startup the development frontend image
171+
- name: Shutdown production frontend
172+
run: |
173+
docker compose -f docker/docker-compose-dist.yml down
174+
sleep 10
175+
docker container ls
176+
- name: Startup development frontend
177+
# Specify the GHCR copy of the development frontend, so that we use the newly built image
178+
env:
179+
DOCKER_REGISTRY: ghcr.io
180+
run: |
181+
docker compose -f docker/docker-compose.yml up -d
182+
sleep 10
183+
docker container ls
184+
# Verify development frontend started successfully.
185+
# 1. First, keep requesting the frontend every 10 seconds to wait until its up. Timeout after 10 minutes.
186+
# 2. Once it's responding, check to see if the word "DSpace" appears.
187+
# We cannot check for anything more specific because development mode doesn't have SSR.
188+
- name: Verify development frontend is responding properly
189+
run: |
190+
timeout 10m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:4000
191+
result=$(wget -O- -q http://127.0.0.1:4000)
192+
echo "$result"
193+
echo "$result" | grep -oE "DSpace"
194+
- name: Error logs of development frontend (if error in startup)
195+
if: ${{ failure() }}
196+
run: |
197+
docker compose -f docker/docker-compose.yml logs
198+
# Shutdown our containers
199+
- name: Shutdown running Docker containers
200+
run: |
201+
docker compose -f docker/docker-compose.yml -f docker/docker-compose-rest.yml down

.github/workflows/issue_opened.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
# Only add to project board if issue is flagged as "needs triage" or has no labels
1717
# NOTE: By default we flag new issues as "needs triage" in our issue template
1818
if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '')
19-
uses: actions/add-to-project@v1.0.0
19+
uses: actions/add-to-project@v1.0.2
2020
# Note, the authentication token below is an ORG level Secret.
2121
# It must be created/recreated manually via a personal access token with admin:org, project, public_repo permissions
2222
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token

.github/workflows/port_merged_pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
if: github.event.pull_request.merged
2424
steps:
2525
# Checkout code
26-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2727
# Port PR to other branch (ONLY if labeled with "port to")
2828
# See https://github.com/korthout/backport-action
2929
- name: Create backport pull requests
30-
uses: korthout/backport-action@v2
30+
uses: korthout/backport-action@v4
3131
with:
3232
# Trigger based on a "port to [branch]" label on PR
3333
# (This label must specify the branch name to port to)

.github/workflows/pull_request_opened.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
# Assign the PR to whomever created it. This is useful for visualizing assignments on project boards
2222
# See https://github.com/toshimaru/auto-author-assign
2323
- name: Assign PR to creator
24-
uses: toshimaru/auto-author-assign@v2.1.0
24+
uses: toshimaru/auto-author-assign@v3.0.1

Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@ ARG DOCKER_REGISTRY=docker.io
88
FROM ${DOCKER_REGISTRY:-docker.io}/4science/dspace-cris-angular-dependencies:${DSPACE_VERSION:-dspace-cris-2024_02_x} AS dev
99

1010
WORKDIR /app
11-
ADD . /app/
12-
EXPOSE 4000
11+
12+
# Copy over package files first, so this layer will only be rebuilt if those files change.
13+
COPY package.json yarn.lock ./
14+
15+
# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com
16+
# See, for example https://github.com/yarnpkg/yarn/issues/5540
17+
RUN yarn install --network-timeout 300000
18+
19+
# Add the rest of the source code
20+
COPY . /app/
1321

1422
# When running in dev mode, 4GB of memory is required to build & launch the app.
1523
# This default setting can be overridden as needed in your shell, via an env file or in docker-compose.
1624
# See Docker environment var precedence: https://docs.docker.com/compose/environment-variables/envvars-precedence/
1725
ENV NODE_OPTIONS="--max_old_space_size=4096"
1826

1927
# On startup, run in DEVELOPMENT mode (this defaults to live reloading enabled, etc).
20-
# Listen / accept connections from all IP addresses.
21-
# NOTE: At this time it is only possible to run Docker container in Production mode
22-
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
2328
ENV NODE_ENV=development
24-
CMD ["yarn", "serve", "--host", "0.0.0.0"]
29+
30+
EXPOSE 4000
31+
32+
# On startup, run this command to start application in dev mode
33+
ENTRYPOINT [ "yarn", "serve" ]
34+
# By default set host to 0.0.0.0 to listen/accept connections from all IP addresses.
35+
# Poll for changes every 5 seconds (if any detected, app will rebuild/restart)
36+
CMD ["--host 0.0.0.0", "--poll 5000"]

Dockerfile.dist

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,31 @@ COPY . /app/
1717

1818
WORKDIR /app
1919

20-
# Build Angular app
20+
# Copy over package files first, so this layer will only be rebuilt if those files change.
21+
COPY package.json yarn.lock ./
22+
RUN yarn install --network-timeout 300000
23+
24+
# Around 4GB of memory is required to build the app for production.
25+
# This default setting can be overridden as needed in your shell, via an env file or in docker-compose.
26+
# See Docker environment var precedence: https://docs.docker.com/compose/environment-variables/envvars-precedence/
27+
ENV NODE_OPTIONS="--max_old_space_size=4096"
28+
29+
2130
RUN yarn build:prod
2231
RUN yarn build:mirador
2332

2433
# ---- Production image ----
2534
FROM docker.io/node:${NODE_VERSION-22}-alpine AS prod
2635

36+
# Copy pre-built code from build image
37+
COPY --chown=node:node --from=build /app/dist /app/dist
38+
# Copy configs and PM2 startup script from local machine
39+
COPY --chown=node:node config /app/config
40+
COPY --chown=node:node docker/dspace-ui.json /app/dspace-ui.json
2741
# Install pm2 globally and clean npm cache
2842
RUN npm install --global pm2 && npm cache clean --force
2943

44+
# Start up UI in PM2 in production mode
3045
WORKDIR /app
3146

3247
# Only copy built files and config
@@ -39,3 +54,8 @@ ENV NODE_ENV=production
3954
EXPOSE 4000
4055

4156
CMD ["pm2-runtime", "start", "dspace-ui.json", "--json"]
57+
58+
# On startup, run start the DSpace UI in PM2
59+
ENTRYPOINT [ "pm2-runtime", "start", "dspace-ui.json" ]
60+
# By default, pass param that specifies to use JSON format logs.
61+
CMD ["--json"]

0 commit comments

Comments
 (0)