Skip to content

Commit ef2ebf3

Browse files
FrancescoMolinaroAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2253 (pull request DSpace#4772)
Task/dspace cris 2023 02 x/DSC-2253 Approved-by: Andrea Barbasso
2 parents fa607b2 + b356745 commit ef2ebf3

402 files changed

Lines changed: 86603 additions & 204423 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.

.eslintrc.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,13 @@
231231
"*.json5"
232232
],
233233
"extends": [
234-
"plugin:jsonc/recommended-with-jsonc"
234+
"plugin:jsonc/recommended-with-json5"
235235
],
236236
"rules": {
237-
"no-irregular-whitespace": "error",
237+
// The ESLint core no-irregular-whitespace rule doesn't work well in JSON
238+
// See: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-irregular-whitespace.html
239+
"no-irregular-whitespace": "off",
240+
"jsonc/no-irregular-whitespace": "error",
238241
"no-trailing-spaces": "error",
239242
"jsonc/comma-dangle": [
240243
"error",

.github/workflows/build.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ 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
3031
# Tell Cypress to run e2e tests using the same UI URL
3132
CYPRESS_BASE_URL: http://127.0.0.1:4000
33+
# Disable the cookie consent banner in e2e tests to avoid errors because of elements hidden by it
34+
DSPACE_INFO_ENABLECOOKIECONSENTPOPUP: false
3235
# When Chrome version is specified, we pin to a specific version of Chrome
3336
# Comment this out to use the latest release
3437
#CHROME_VERSION: "116.0.5845.187-1"
@@ -49,11 +52,11 @@ jobs:
4952
steps:
5053
# https://github.com/actions/checkout
5154
- name: Checkout codebase
52-
uses: actions/checkout@v4
55+
uses: actions/checkout@v6
5356

5457
# https://github.com/actions/setup-node
5558
- name: Install Node.js ${{ matrix.node-version }}
56-
uses: actions/setup-node@v4
59+
uses: actions/setup-node@v6
5760
with:
5861
node-version: ${{ matrix.node-version }}
5962

@@ -78,7 +81,7 @@ jobs:
7881
id: yarn-cache-dir-path
7982
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
8083
- name: Cache Yarn dependencies
81-
uses: actions/cache@v4
84+
uses: actions/cache@v5
8285
with:
8386
# Cache entire Yarn cache directory (see previous step)
8487
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -105,16 +108,21 @@ jobs:
105108
# so that it can be shared with the 'codecov' job (see below)
106109
# NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286
107110
- name: Upload code coverage report to Artifact
108-
uses: actions/upload-artifact@v4
111+
uses: actions/upload-artifact@v7
109112
if: matrix.node-version == '18.x'
110113
with:
111114
name: coverage-report-${{ matrix.node-version }}
112115
path: 'coverage/dspace-angular/lcov.info'
113116
retention-days: 14
114117

115-
# Login to our Docker registry, so that we can access private Docker images using "docker compose" below.
118+
# Login to our Docker registry, so that we can access Docker images using "docker compose" below.
119+
# This login is required on the upstream repository because DOCKER_REGISTRY is set to ghcr.io
120+
# and pulling ghcr.io/dspace/* requires authentication. On forks, DOCKER_REGISTRY falls back to
121+
# docker.io (see env block above) where the same images are publicly pullable without a login,
122+
# and forks cannot authenticate against ghcr.io/dspace/* with their own GITHUB_TOKEN anyway.
116123
- name: Login to ${{ env.DOCKER_REGISTRY }}
117-
uses: docker/login-action@v3
124+
uses: docker/login-action@v4
125+
if: github.repository == 'dspace/dspace-angular'
118126
with:
119127
registry: ${{ env.DOCKER_REGISTRY }}
120128
username: ${{ github.repository_owner }}
@@ -132,7 +140,7 @@ jobs:
132140
# https://github.com/cypress-io/github-action
133141
# (NOTE: to run these e2e tests locally, just use 'ng e2e')
134142
- name: Run e2e tests (integration tests)
135-
uses: cypress-io/github-action@v6
143+
uses: cypress-io/github-action@v7.1.9
136144
with:
137145
# Run tests in Chrome, headless mode (default)
138146
browser: chrome
@@ -147,7 +155,7 @@ jobs:
147155
# Cypress always creates a video of all e2e tests (whether they succeeded or failed)
148156
# Save those in an Artifact
149157
- name: Upload e2e test videos to Artifacts
150-
uses: actions/upload-artifact@v4
158+
uses: actions/upload-artifact@v7
151159
if: always()
152160
with:
153161
name: e2e-test-videos-${{ matrix.node-version }}
@@ -156,7 +164,7 @@ jobs:
156164
# If e2e tests fail, Cypress creates a screenshot of what happened
157165
# Save those in an Artifact
158166
- name: Upload e2e test failure screenshots to Artifacts
159-
uses: actions/upload-artifact@v4
167+
uses: actions/upload-artifact@v7
160168
if: failure()
161169
with:
162170
name: e2e-test-screenshots-${{ matrix.node-version }}
@@ -203,22 +211,25 @@ jobs:
203211
codecov:
204212
# Must run after 'tests' job above
205213
needs: tests
214+
# Only run on the upstream repository: forks do not have the CODECOV_TOKEN secret,
215+
# and Codecov refuses to create a commit on a protected branch without a token.
216+
if: github.repository == 'dspace/dspace-angular'
206217
runs-on: ubuntu-latest
207218
steps:
208219
- name: Checkout
209-
uses: actions/checkout@v4
220+
uses: actions/checkout@v6
210221

211222
# Download artifacts from previous 'tests' job
212223
- name: Download coverage artifacts
213-
uses: actions/download-artifact@v4
224+
uses: actions/download-artifact@v8
214225

215226
# Now attempt upload to Codecov using its action.
216227
# NOTE: We use a retry action to retry the Codecov upload if it fails the first time.
217228
#
218229
# Retry action: https://github.com/marketplace/actions/retry-action
219230
# Codecov action: https://github.com/codecov/codecov-action
220231
- name: Upload coverage to Codecov.io
221-
uses: Wandalen/wretry.action@v1.3.0
232+
uses: Wandalen/wretry.action@v3.8.0
222233
with:
223234
action: codecov/codecov-action@v4
224235
# 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: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,123 @@ jobs:
5757
# Enable redeploy of sandbox & demo if the branch for this image matches the deployment branch of
5858
# these sites as specified in reusable-docker-build.xml
5959
REDEPLOY_SANDBOX_URL: ${{ secrets.REDEPLOY_SANDBOX_URL }}
60-
REDEPLOY_DEMO_URL: ${{ secrets.REDEPLOY_DEMO_URL }}
60+
REDEPLOY_DEMO_URL: ${{ secrets.REDEPLOY_DEMO_URL }}
61+
62+
#################################################################################
63+
# Test Deployment via Docker to ensure newly built images are working properly
64+
#################################################################################
65+
docker-deploy:
66+
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
67+
if: github.repository == 'dspace/dspace-angular'
68+
runs-on: ubuntu-latest
69+
# Must run after all major images are built
70+
needs: [dspace-angular, dspace-angular-dist]
71+
env:
72+
# Override default dspace.server.url & REST 'host' because backend starts at http://127.0.0.1:8080
73+
dspace__P__server__P__url: http://127.0.0.1:8080/server
74+
DSPACE_REST_HOST: 127.0.0.1
75+
# Override default dspace.ui.url to also use 127.0.0.1.
76+
dspace__P__ui__P__url: http://127.0.0.1:4000
77+
# Override default ui.baseUrl to also use 127.0.0.1. This should match 'dspace.ui.url'.
78+
DSPACE_UI_BASEURL: http://127.0.0.1:4000
79+
steps:
80+
# Checkout our codebase (to get access to Docker Compose scripts)
81+
- name: Checkout codebase
82+
uses: actions/checkout@v6
83+
# Download Docker image artifacts (which were just built by reusable-docker-build.yml)
84+
- name: Download Docker image artifacts
85+
uses: actions/download-artifact@v8
86+
with:
87+
# Download all amd64 Docker images (TAR files) into the /tmp/docker directory
88+
pattern: docker-image-*-linux-amd64
89+
path: /tmp/docker
90+
merge-multiple: true
91+
# Load each of the images into Docker by calling "docker image load" for each.
92+
# This ensures we are using the images just built & not any prior versions on DockerHub
93+
- name: Load all downloaded Docker images
94+
run: |
95+
find /tmp/docker -type f -name "*.tar" -exec docker image load --input "{}" \;
96+
docker image ls -a
97+
# Start backend using our compose script in the codebase.
98+
- name: Start backend in Docker
99+
# MUST use docker.io as we don't have a copy of this backend image in our GitHub Action,
100+
# and docker.io is the only public image. If we ever hit aggressive rate limits at DockerHub,
101+
# we may need to consider making the 'ghcr.io' images public & switch this to 'ghcr.io'
102+
env:
103+
DOCKER_REGISTRY: docker.io
104+
run: |
105+
docker compose -f docker/docker-compose-rest.yml up -d
106+
sleep 10
107+
docker container ls
108+
# Create a test admin account. Load test data from a simple set of AIPs as defined in cli.ingest.yml
109+
# NOTE: Before creating test data, we wait for the backend to become responsive by requesting it every 10 sec.
110+
# Timeout after 5 minutes. This is done to ensure the backend is fully initialized before we create test data.
111+
- name: Load test data into Backend
112+
run: |
113+
timeout 5m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:8080/server/api
114+
docker compose -f docker/cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
115+
docker compose -f docker/cli.yml -f docker/cli.ingest.yml run --rm dspace-cli
116+
# Verify backend started successfully.
117+
# 1. Make sure root endpoint is responding (check for dspace.name defined in docker-compose.yml)
118+
# 2. Also check /collections endpoint to ensure the test data loaded properly (check for a collection name in AIPs)
119+
- name: Verify backend is responding properly
120+
run: |
121+
result=$(wget -O- -q http://127.0.0.1:8080/server/api)
122+
echo "$result"
123+
echo "$result" | grep -oE "\"DSpace Started with Docker Compose\""
124+
result=$(wget -O- -q http://127.0.0.1:8080/server/api/core/collections)
125+
echo "$result"
126+
echo "$result" | grep -oE "\"Dog in Yard\""
127+
# Start production frontend using our compose script in the codebase.
128+
- name: Start production frontend in Docker
129+
# Specify the GHCR copy of the production frontend, so that we use the newly built image
130+
env:
131+
DOCKER_REGISTRY: ghcr.io
132+
run: |
133+
docker compose -f docker/docker-compose-dist.yml up -d
134+
sleep 10
135+
docker container ls
136+
# Verify production frontend started successfully.
137+
# 1. Make sure /home path has "DSpace software" (this is in the footer of the page)
138+
# 2. Also check /community-list page lists one of the test Communities in the loaded test data
139+
- name: Verify production frontend is responding properly
140+
run: |
141+
result=$(wget -O- -q http://127.0.0.1:4000/home)
142+
echo "$result"
143+
echo "$result" | grep -oE "DSpace software"
144+
- name: Error logs of production frontend (if error in startup)
145+
if: ${{ failure() }}
146+
run: |
147+
docker compose -f docker/docker-compose-dist.yml logs
148+
# Now shutdown the production frontend image and startup the development frontend image
149+
- name: Shutdown production frontend
150+
run: |
151+
docker compose -f docker/docker-compose-dist.yml down
152+
sleep 10
153+
docker container ls
154+
- name: Startup development frontend
155+
# Specify the GHCR copy of the development frontend, so that we use the newly built image
156+
env:
157+
DOCKER_REGISTRY: ghcr.io
158+
run: |
159+
docker compose -f docker/docker-compose.yml up -d
160+
sleep 10
161+
docker container ls
162+
# Verify development frontend started successfully.
163+
# 1. First, keep requesting the frontend every 10 seconds to wait until its up. Timeout after 10 minutes.
164+
# 2. Once it's responding, check to see if the word "DSpace" appears.
165+
# We cannot check for anything more specific because development mode doesn't have SSR.
166+
- name: Verify development frontend is responding properly
167+
run: |
168+
timeout 10m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:4000
169+
result=$(wget -O- -q http://127.0.0.1:4000)
170+
echo "$result"
171+
echo "$result" | grep -oE "DSpace"
172+
- name: Error logs of development frontend (if error in startup)
173+
if: ${{ failure() }}
174+
run: |
175+
docker compose -f docker/docker-compose.yml logs
176+
# Shutdown our containers
177+
- name: Shutdown running Docker containers
178+
run: |
179+
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: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
# This image will be published as dspace/dspace-angular
22
# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details
33

4-
FROM docker.io/node:18-alpine
4+
FROM docker.io/node:22-alpine
55

66
# Ensure Python and other build tools are available
77
# These are needed to install some node modules, especially on linux/arm64
88
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
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 ./
1314

1415
# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com
1516
# See, for example https://github.com/yarnpkg/yarn/issues/5540
1617
RUN yarn install --network-timeout 300000
1718

19+
# Add the rest of the source code
20+
COPY . /app/
21+
1822
# When running in dev mode, 4GB of memory is required to build & launch the app.
1923
# This default setting can be overridden as needed in your shell, via an env file or in docker-compose.
2024
# See Docker environment var precedence: https://docs.docker.com/compose/environment-variables/envvars-precedence/
2125
ENV NODE_OPTIONS="--max_old_space_size=4096"
2226

2327
# On startup, run in DEVELOPMENT mode (this defaults to live reloading enabled, etc).
24-
# Listen / accept connections from all IP addresses.
25-
# NOTE: At this time it is only possible to run Docker container in Production mode
26-
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
2728
ENV NODE_ENV=development
28-
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"]

0 commit comments

Comments
 (0)