Skip to content

Commit 3168788

Browse files
committed
Merge branch 'main' into 176-full-color-demo
2 parents 49d45ad + 32a3bab commit 3168788

File tree

22 files changed

+545
-220
lines changed

22 files changed

+545
-220
lines changed

.github/workflows/build.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Build Docker Images"
2+
run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
inputs:
12+
debug_enabled:
13+
type: boolean
14+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
15+
required: false
16+
default: false
17+
18+
env:
19+
REGISTRY: ghcr.io
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
steps:
28+
- id: setup
29+
name: Setup
30+
uses: scientist-softserv/actions/[email protected]
31+
with:
32+
tag: ${{ inputs.tag }}
33+
image_name: ${{ inputs.image_name }}
34+
token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
35+
- uses: actions/setup-node@v3
36+
with:
37+
registry-url: 'https://npm.pkg.github.com'
38+
# Defaults to the user or organization that owns the workflow file
39+
scope: '@scientist-softserv'
40+
node-version-file: package.json
41+
- name: GPR authToken
42+
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > $NPM_CONFIG_USERCONFIG
43+
- name: GPR alias
44+
run: echo "@scientist-softserv:registry=https://npm.pkg.github.com" >> $NPM_CONFIG_USERCONFIG
45+
- run: yarn install
46+
- run: yarn test
47+
48+
- name: Login to GitHub Container Registry
49+
uses: docker/login-action@v2
50+
with:
51+
registry: ${{ env.REGISTRY }}
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Retag action for Docker image
56+
id: meta-docker-image
57+
uses: docker/[email protected]
58+
with:
59+
images: |
60+
name=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}
61+
tags: |
62+
type=raw,value=latest,enable={{is_default_branch}}
63+
64+
- run: cp $NPM_CONFIG_USERCONFIG .npmrc; cat .npmrc
65+
66+
- name: Build and push Docker image
67+
uses: docker/build-push-action@v3
68+
with:
69+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
70+
context: .
71+
push: true
72+
tags: |
73+
${{ steps.meta-docker-image.outputs.tags }}
74+
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}

.github/workflows/deploy.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Deploy"
2+
run-name: Deploy (${{ github.ref_name }} -> ${{ inputs.environment }}) by @${{ github.actor }}
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Deploy to Environment'
8+
required: true
9+
default: 'staging'
10+
type: choice
11+
options:
12+
- staging
13+
debug_enabled:
14+
type: boolean
15+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
16+
required: false
17+
default: false
18+
19+
jobs:
20+
deploy:
21+
uses: scientist-softserv/actions/.github/workflows/[email protected]
22+
secrets: inherit

.github/workflows/docker-build.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Preparing your local copy of the component library:
5151
npm install
5252
yarn link # now there is a magic symlink in `~/.config/yarn/link` usable by the webstore app
5353

54-
And you have to decide how often you want to rebuild the component library:
54+
If there are changes to the component library, you will need to rebuild in order to get the newest changes. You can either rebuild manually after changes are made, or have the webstore continually "watch" for changes:
5555

5656
npm run build-lib # for a onetime build
5757
npm run watch-lib # for a continuous build

bin/helm_deploy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
# This script wraps up helm deployment. It is meant as a clear starting point for
4+
# commandline deployment or CI based deployment. It requires the following ENV vars be set
5+
#
6+
# CHART_VERSION: this is the version of the hyrax chart you want to deploy. default - 0.22.0
7+
# DEPLOY_IMAGE: this is the build image that runs the rails application. Typically this would run puma or passenger. eg: samvera/hyrax or ghcr.io/samvera/hyku. Defaults to gcrh.io/samvera/hyku
8+
# DEPLOY_TAG: name of of the tag you want to deploy for deploy image. eg: "latest" or "v3.0.1" or "f123asdf1". Defaults to latest
9+
# HELM_EXTRA_ARGS: any additional arguments you'd like passed to helm upgrade directly. can be blank.
10+
11+
if [ -z "$1" ] || [ -z "$2" ]
12+
then
13+
echo './bin/helm_deploy RELEASE_NAME NAMESPACE'
14+
exit 1
15+
fi
16+
release_name="${1}"
17+
namespace="${2}"
18+
19+
DEPLOY_IMAGE="${DEPLOY_IMAGE:-ghcr.io/scientist-softserv/webstore}"
20+
DEPLOY_TAG="${DEPLOY_TAG:-latest}"
21+
22+
helm upgrade \
23+
--install \
24+
--atomic \
25+
--timeout 15m0s \
26+
--set image.repository="$DEPLOY_IMAGE" \
27+
--set image.tag="$DEPLOY_TAG" \
28+
$HELM_EXTRA_ARGS \
29+
--namespace="$namespace" \
30+
--create-namespace \
31+
"$release_name" \
32+
./charts/webstore

charts/webstore/templates/deployment.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ spec:
3333
{{- toYaml .Values.securityContext | nindent 12 }}
3434
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
3535
imagePullPolicy: {{ .Values.image.pullPolicy }}
36-
envFrom:
37-
- secretRef:
38-
name: {{ .Values.apiTokenConfigSecret }}
3936
env:
4037
- name: NEXTAUTH_URL
4138
value: "{{ .Values.nextAuthUrl }}"
@@ -45,6 +42,14 @@ spec:
4542
value: "{{ .Values.providerId }}"
4643
- name: NEXT_PUBLIC_SCIENTIST_API_VERSION
4744
value: "{{ .Values.scientistApiVersion }}"
45+
- name: NEXT_PUBLIC_TOKEN
46+
value: "{{ .Values.nextPublicToken }}"
47+
- name: NEXTAUTH_SECRET
48+
value: "{{ .Values.nextAuthSecret }}"
49+
- name: CLIENT_SECRET
50+
value: "{{ .Values.clientSecret }}"
51+
- name: CLIENT_ID
52+
value: "{{ .Values.clientId }}"
4853
ports:
4954
- name: http
5055
containerPort: {{ .Values.service.port }}

charts/webstore/values/webstore-staging.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

cypress/e2e/requests.cy.js

Lines changed: 112 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,118 @@
11
describe('Viewing all requests', () => {
2-
it('does not show a request list if the user is logged out.', () => {
3-
// Visit a protected route in order to allow cypress to set the cookie and mock the login
4-
cy.visit("/requests")
5-
6-
cy.get('div.alert-heading').contains('Unauthorized').then(() => {
7-
cy.log("A logged out user is not able to view requests.")
8-
})
9-
})
2+
describe('as a logged out user', () => {
3+
it('should show an error message.', () => {
4+
// Visit a protected route in order to allow cypress to set the cookie and mock the login
5+
cy.visit('/requests')
6+
cy.get('div.alert-heading').contains('Unauthorized').then(() => {
7+
cy.log('A logged out user is not able to view requests.')
8+
})
9+
})
10+
})
1011

11-
it("shows the user's request list if they are logged in.", () => {
12-
// Call the custom cypress command to log in
13-
cy.login(Cypress.env('TEST_SCIENTIST_USER'), Cypress.env('TEST_SCIENTIST_PW'))
12+
describe('as a logged in user', () => {
13+
let scientistApiBaseURL = `https://${Cypress.env('NEXT_PUBLIC_PROVIDER_NAME')}.scientist.com/api/v2`
14+
// declare variables that can be used to change how the response is intercepted.
15+
let requestList
16+
let loading
17+
let error
1418

15-
// Visit a protected route in order to allow cypress to set the cookie and mock the login
16-
cy.visit("/requests")
19+
beforeEach(() => {
20+
// Call the custom cypress command to log in
21+
cy.login(Cypress.env('TEST_SCIENTIST_USER'), Cypress.env('TEST_SCIENTIST_PW'))
22+
// Intercept the response from the endpoint to view all requests
23+
// TODO(summer-cook): extract out this base url into the config to use as an environment variable. it was not cooperating before
24+
cy.intercept('GET', `${scientistApiBaseURL}/quote_groups/mine.json`, (req) => {
25+
switch (true) {
26+
// reply with an empty response: both data and error will be undefined.
27+
case loading: req.reply()
28+
break
1729

18-
// check that either the requests are showing, or that the user has no requests
19-
const requestListExists = cy.get('article.request-item').should('exist') ||
20-
cy.get('p.no-requests').contains('You do not have any requests yet.')
30+
// error will be defined
31+
case error: req.reply({ statusCode: 500 })
32+
break
2133

22-
requestListExists.then(() => {
23-
cy.log('Successfully logged in and viewing request list')
24-
})
25-
})
34+
case requestList: req.reply({ fixture: 'all-requests/requests.json' })
35+
break
36+
37+
// reply with a request body- default status code is 200
38+
case !requestList: req.reply({ fixture: 'all-requests/no-requests.json' })
39+
break
40+
}
41+
})
42+
// Intercept the response from the endpoint that gets the default ware ID
43+
cy.intercept('GET', `${scientistApiBaseURL}/wares.json?q=make-a-request`, (req) => {
44+
switch (true) {
45+
case error: req.reply({ statusCode: 500 })
46+
break
47+
48+
default: req.reply({ fixture: 'all-requests/make-a-request.json' })
49+
break
50+
}
51+
})
52+
cy.visit('/requests')
53+
})
54+
55+
56+
context('request list is loading', () => {
57+
before(() => {
58+
loading = true
59+
})
60+
it('should show a loading spinner.', () => {
61+
cy.get("[aria-label='tail-spin-loading']").should('be.visible').then(() => {
62+
cy.log('Loading spinner displays correctly.')
63+
})
64+
})
65+
})
66+
67+
context('error while making a request to the api', () => {
68+
before(() => {
69+
requestList = undefined
70+
loading = false
71+
error = true
72+
})
73+
it('should show an error message.', () => {
74+
cy.get("div[role='alert']").should('be.visible').then(() => {
75+
cy.log('Successfully hits an error.')
76+
})
77+
})
78+
})
79+
80+
describe('request components are loading successfully, &', () => {
81+
context('the user has requests', () => {
82+
before(() => {
83+
requestList = true
84+
error = false
85+
})
86+
it("should show the user's request list.", () => {
87+
cy.get('article.request-item').should('exist').then(() => {
88+
cy.log('Successfully viewing request list.')
89+
})
90+
})
91+
})
92+
93+
context('the user has 0 requests', () => {
94+
before(() => {
95+
requestList = false
96+
})
97+
it("should show a message notifying the user they don't have any requests.", () => {
98+
cy.get('p.no-requests').contains('You do not have any requests yet.').then(() => {
99+
cy.log('Successfully viewing request page with no requests.')
100+
})
101+
})
102+
})
103+
104+
context('the user can see the <LinkedButton /> component', () => {
105+
[true, false].forEach((value) => {
106+
before(() => {
107+
requestList = value
108+
})
109+
it(`should show a button that links to the initialize request page for the default ware ${value ? 'with a request list' : 'with 0 requests'}.`, () => {
110+
cy.get("a[data-cy='linked-button']").should('have.attr', 'href', `/requests/new/make-a-request?id=123`).then(() => {
111+
cy.log('The <LinkedButton /> component displays correctly')
112+
})
113+
})
114+
})
115+
})
116+
})
117+
})
26118
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ware_refs": [
3+
{
4+
"id": 123
5+
}
6+
]
7+
}

0 commit comments

Comments
 (0)