@@ -7,7 +7,8 @@ name: Build
77on : [push, pull_request]
88
99permissions :
10- contents : read # to fetch code (actions/checkout)
10+ contents : read # to fetch code (actions/checkout)
11+ packages : read # to fetch private images from GitHub Container Registry (GHCR)
1112
1213jobs :
1314 tests :
@@ -33,21 +34,26 @@ jobs:
3334 # CHROME_VERSION: "90.0.4430.212-1"
3435 # Bump Node heap size (OOM in CI after upgrading to Angular 15)
3536 NODE_OPTIONS : ' --max-old-space-size=4096'
37+ # Project name to use when running "docker compose" prior to e2e tests
38+ COMPOSE_PROJECT_NAME : ' ci'
39+ # Docker Registry to use for Docker compose scripts below.
40+ # We use GitHub's Container Registry to avoid aggressive rate limits at DockerHub.
41+ DOCKER_REGISTRY : ghcr.io
3642 strategy :
3743 # Create a matrix of Node versions to test against (in parallel)
3844 matrix :
39- node-version : [16 .x, 18 .x]
45+ node-version : [18 .x, 20 .x]
4046 # Do NOT exit immediately if one matrix job fails
4147 fail-fast : false
4248 # These are the actual CI steps to perform per job
4349 steps :
4450 # https://github.com/actions/checkout
4551 - name : Checkout codebase
46- uses : actions/checkout@v3
52+ uses : actions/checkout@v4
4753
4854 # https://github.com/actions/setup-node
4955 - name : Install Node.js ${{ matrix.node-version }}
50- uses : actions/setup-node@v3
56+ uses : actions/setup-node@v4
5157 with :
5258 node-version : ${{ matrix.node-version }}
5359
7278 id : yarn-cache-dir-path
7379 run : echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
7480 - name : Cache Yarn dependencies
75- uses : actions/cache@v3
81+ uses : actions/cache@v4
7682 with :
7783 # Cache entire Yarn cache directory (see previous step)
7884 path : ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -99,26 +105,34 @@ jobs:
99105 # so that it can be shared with the 'codecov' job (see below)
100106 # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286
101107 - name : Upload code coverage report to Artifact
102- uses : actions/upload-artifact@v3
108+ uses : actions/upload-artifact@v4
103109 if : matrix.node-version == '18.x'
104110 with :
105- name : dspace-angular coverage report
111+ name : coverage-report-${{ matrix.node-version }}
106112 path : ' coverage/dspace-angular/lcov.info'
107113 retention-days : 14
108114
109- # Using docker-compose start backend using CI configuration
115+ # Login to our Docker registry, so that we can access private Docker images using "docker compose" below.
116+ - name : Login to ${{ env.DOCKER_REGISTRY }}
117+ uses : docker/login-action@v3
118+ with :
119+ registry : ${{ env.DOCKER_REGISTRY }}
120+ username : ${{ github.repository_owner }}
121+ password : ${{ secrets.GITHUB_TOKEN }}
122+
123+ # Using "docker compose" start backend using CI configuration
110124 # and load assetstore from a cached copy
111125 - name : Start DSpace REST Backend via Docker (for e2e tests)
112126 run : |
113- docker- compose -f ./docker/docker-compose-ci.yml up -d
114- docker- compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli
127+ docker compose -f ./docker/docker-compose-ci.yml up -d
128+ docker compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli
115129 docker container ls
116130
117131 # Run integration tests via Cypress.io
118132 # https://github.com/cypress-io/github-action
119133 # (NOTE: to run these e2e tests locally, just use 'ng e2e')
120134 - name : Run e2e tests (integration tests)
121- uses : cypress-io/github-action@v5
135+ uses : cypress-io/github-action@v6
122136 with :
123137 # Run tests in Chrome, headless mode (default)
124138 browser : chrome
@@ -133,19 +147,19 @@ jobs:
133147 # Cypress always creates a video of all e2e tests (whether they succeeded or failed)
134148 # Save those in an Artifact
135149 - name : Upload e2e test videos to Artifacts
136- uses : actions/upload-artifact@v3
150+ uses : actions/upload-artifact@v4
137151 if : always()
138152 with :
139- name : e2e-test-videos
153+ name : e2e-test-videos-${{ matrix.node-version }}
140154 path : cypress/videos
141155
142156 # If e2e tests fail, Cypress creates a screenshot of what happened
143157 # Save those in an Artifact
144158 - name : Upload e2e test failure screenshots to Artifacts
145- uses : actions/upload-artifact@v3
159+ uses : actions/upload-artifact@v4
146160 if : failure()
147161 with :
148- name : e2e-test-screenshots
162+ name : e2e-test-screenshots-${{ matrix.node-version }}
149163 path : cypress/screenshots
150164
151165 - name : Stop app (in case it stays up after e2e tests)
@@ -170,17 +184,89 @@ jobs:
170184 # Get homepage and verify that the <meta name="title"> tag includes "DSpace".
171185 # If it does, then SSR is working, as this tag is created by our MetadataService.
172186 # This step also prints entire HTML of homepage for easier debugging if grep fails.
173- - name : Verify SSR (server-side rendering)
187+ - name : Verify SSR (server-side rendering) on Homepage
174188 run : |
175189 result=$(wget -O- -q http://127.0.0.1:4000/home)
176190 echo "$result"
177191 echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep DSpace
178192
193+ # Get a specific community in our test data and verify that the "<h1>" tag includes "Publications" (the community name).
194+ # If it does, then SSR is working.
195+ - name : Verify SSR on a Community page
196+ run : |
197+ result=$(wget -O- -q http://127.0.0.1:4000/communities/0958c910-2037-42a9-81c7-dca80e3892b4)
198+ echo "$result"
199+ echo "$result" | grep -oE "<h1 [^>]*>[^><]*</h1>" | grep Publications
200+
201+ # Get a specific collection in our test data and verify that the "<h1>" tag includes "Articles" (the collection name).
202+ # If it does, then SSR is working.
203+ - name : Verify SSR on a Collection page
204+ run : |
205+ result=$(wget -O- -q http://127.0.0.1:4000/collections/282164f5-d325-4740-8dd1-fa4d6d3e7200)
206+ echo "$result"
207+ echo "$result" | grep -oE "<h1 [^>]*>[^><]*</h1>" | grep Articles
208+
209+ # Get a specific publication in our test data and verify that the <meta name="title"> tag includes
210+ # the title of this publication. If it does, then SSR is working.
211+ - name : Verify SSR on a Publication page
212+ run : |
213+ result=$(wget -O- -q http://127.0.0.1:4000/entities/publication/6160810f-1e53-40db-81ef-f6621a727398)
214+ echo "$result"
215+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "An Economic Model of Mortality Salience"
216+
217+ # Get a specific person in our test data and verify that the <meta name="title"> tag includes
218+ # the name of the person. If it does, then SSR is working.
219+ - name : Verify SSR on a Person page
220+ run : |
221+ result=$(wget -O- -q http://127.0.0.1:4000/entities/person/b1b2c768-bda1-448a-a073-fc541e8b24d9)
222+ echo "$result"
223+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Simmons, Cameron"
224+
225+ # Get a specific project in our test data and verify that the <meta name="title"> tag includes
226+ # the name of the project. If it does, then SSR is working.
227+ - name : Verify SSR on a Project page
228+ run : |
229+ result=$(wget -O- -q http://127.0.0.1:4000/entities/project/46ccb608-a74c-4bf6-bc7a-e29cc7defea9)
230+ echo "$result"
231+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "University Research Fellowship"
232+
233+ # Get a specific orgunit in our test data and verify that the <meta name="title"> tag includes
234+ # the name of the orgunit. If it does, then SSR is working.
235+ - name : Verify SSR on an OrgUnit page
236+ run : |
237+ result=$(wget -O- -q http://127.0.0.1:4000/entities/orgunit/9851674d-bd9a-467b-8d84-068deb568ccf)
238+ echo "$result"
239+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Law and Development"
240+
241+ # Get a specific journal in our test data and verify that the <meta name="title"> tag includes
242+ # the name of the journal. If it does, then SSR is working.
243+ - name : Verify SSR on a Journal page
244+ run : |
245+ result=$(wget -O- -q http://127.0.0.1:4000/entities/journal/d4af6c3e-53d0-4757-81eb-566f3b45d63a)
246+ echo "$result"
247+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Environmental & Architectural Phenomenology"
248+
249+ # Get a specific journal volume in our test data and verify that the <meta name="title"> tag includes
250+ # the name of the volume. If it does, then SSR is working.
251+ - name : Verify SSR on a Journal Volume page
252+ run : |
253+ result=$(wget -O- -q http://127.0.0.1:4000/entities/journalvolume/07c6249f-4bf7-494d-9ce3-6ffdb2aed538)
254+ echo "$result"
255+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Environmental & Architectural Phenomenology Volume 28 (2017)"
256+
257+ # Get a specific journal issue in our test data and verify that the <meta name="title"> tag includes
258+ # the name of the issue. If it does, then SSR is working.
259+ - name : Verify SSR on a Journal Issue page
260+ run : |
261+ result=$(wget -O- -q http://127.0.0.1:4000/entities/journalissue/44c29473-5de2-48fa-b005-e5029aa1a50b)
262+ echo "$result"
263+ echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Environmental & Architectural Phenomenology Vol. 28, No. 1"
264+
179265 - name : Stop running app
180266 run : kill -9 $(lsof -t -i:4000)
181267
182268 - name : Shutdown Docker containers
183- run : docker- compose -f ./docker/docker-compose-ci.yml down
269+ run : docker compose -f ./docker/docker-compose-ci.yml down
184270
185271 # Codecov upload is a separate job in order to allow us to restart this separate from the entire build/test
186272 # job above. This is necessary because Codecov uploads seem to randomly fail at times.
@@ -191,22 +277,27 @@ jobs:
191277 runs-on : ubuntu-latest
192278 steps :
193279 - name : Checkout
194- uses : actions/checkout@v3
280+ uses : actions/checkout@v4
195281
196282 # Download artifacts from previous 'tests' job
197283 - name : Download coverage artifacts
198- uses : actions/download-artifact@v3
284+ uses : actions/download-artifact@v4
199285
200286 # Now attempt upload to Codecov using its action.
201287 # NOTE: We use a retry action to retry the Codecov upload if it fails the first time.
202288 #
203289 # Retry action: https://github.com/marketplace/actions/retry-action
204290 # Codecov action: https://github.com/codecov/codecov-action
205291 - name : Upload coverage to Codecov.io
206- uses : Wandalen/wretry.action@v1.0.36
292+ uses : Wandalen/wretry.action@v1.3.0
207293 with :
208- action : codecov/codecov-action@v3
209- # Try upload 5 times max
294+ action : codecov/codecov-action@v4
295+ # Ensure codecov-action throws an error when it fails to upload
296+ # This allows us to auto-restart the action if an error is thrown
297+ with : |
298+ fail_ci_if_error: true
299+ token: ${{ secrets.CODECOV_TOKEN }}
300+ # Try re-running action 5 times max
210301 attempt_limit : 5
211302 # Run again in 30 seconds
212303 attempt_delay : 30000
0 commit comments