-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add R API container to dev dependencies script, and consume R API from app #10
Changes from all commits
1587ce4
704d4b7
985a75f
3c98f7c
ee643a0
18cb9e4
d4c216e
e8567db
e8ffe19
7ee6a28
d14a0eb
7669aa7
f187eeb
1897a64
77e31a4
5aa5870
234bac2
418189f
94612e8
a978237
b2ce44c
2bff65b
fb2bf48
7f44bc5
776d3a8
1eabcfc
1c9e574
276e91e
76bef3b
0357db4
68a2047
e1921c8
2c94900
1a4715e
ee66623
18d6ea1
11801e2
871bb3d
43d47b0
d45d437
c70b3aa
4d8f286
54aa577
6e0ed26
1a82a3b
a2bfe29
c862e0f
5d875f7
5de1f22
6cfc4bd
0701f44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
CI=0 | ||
DATABASE_URL="postgresql://daedalus-web-app-user:changeme@localhost:5432/daedalus-web-app" | ||
NUXT_R_API_BASE=http://localhost:8001/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Integration tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '*' | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Start API server with Mockoon to mock R API | ||
uses: mockoon/cli-action@v2 | ||
with: | ||
data-file: ./mocks/mockoon.json | ||
port: 8001 | ||
- name: Check mocked R API server is running | ||
run: curl -s http://localhost:8001/mock-smoke | ||
- name: Set environment variables for app | ||
run: scripts/ci/copy-env-vars-to-dot-env-file | ||
env: | ||
NUXT_R_API_BASE: ${{ vars.NUXT_R_API_BASE }} | ||
# Note - non-secret variables are stored under the 'vars' context, while secrets will be stored under the 'secrets' context | ||
- name: Test | ||
run: npm run test:integration |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,13 @@ | |
<!-- Use CoreUI Sidebar Header component instead of footer so that stylings for CoreUI Sidebar Brand component work --> | ||
<CSidebarBrand> | ||
<div class="sidebar-brand-full"> | ||
<img class="img-fluid mb-1" src="~/assets/img/IMPERIAL_JAMEEL_INSTITUTE_LOCKUP-p-500.png" alt="Imperial College and Community Jameel logo"> | ||
<img | ||
data-testid="logo" | ||
class="img-fluid mb-1" | ||
:title="versionTooltipContent" | ||
src="~/assets/img/IMPERIAL_JAMEEL_INSTITUTE_LOCKUP-p-500.png" | ||
alt="Imperial College and Community Jameel logo" | ||
> | ||
</div> | ||
</CSidebarBrand> | ||
</CSidebarHeader> | ||
|
@@ -51,38 +57,47 @@ | |
|
||
<script lang="ts" setup> | ||
import { CIcon } from "@coreui/icons-vue"; | ||
import type { VersionData } from "@/types/daedalusApiResponseTypes"; | ||
|
||
const { data: versionData } = useFetch("/api/versions") as { data: Ref<VersionData> }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems likely that this pattern will be repeated a lot, so we'll probably eventually want a generic typs something like
so then this line would become ..but then I suspect maybe we'll also eventually have some sort of UPDATE: I see below that you've got There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, exactly. I think probably the response types from the R API (used in the web app backend) and the types from the web app backend (used in the front end) should probably live in different modules, and maybe a "shared" module for ones that happen to be the same, with whatever generic classes are useful in the two contexts. Maybe |
||
|
||
const versionTooltipContent = computed(() => { | ||
if (versionData.value) { | ||
return `Model version: ${versionData.value.daedalusModel} \nR API version: ${versionData.value.daedalusApi} \nWeb app version: ${versionData.value.daedalusWebApp}`; | ||
} else { | ||
return undefined; | ||
} | ||
}); | ||
|
||
const visible = defineModel("visible", { type: Boolean, required: true }); | ||
const largeScreen = ref(true); | ||
|
||
const breakpoint = 992; // CoreUI's "lg" breakpoint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From here on in this file the changes are only formatting. |
||
const resetSidebarPerScreenSize = () => { | ||
// Set the default values for the sidebar based on the screen size. | ||
if (window.innerWidth < breakpoint) { | ||
visible.value = false; | ||
largeScreen.value = false; | ||
} else { | ||
visible.value = true; | ||
largeScreen.value = true; | ||
} | ||
}; | ||
|
||
const hideHasNeverBeenEmitted = ref(true); | ||
function handleHide() { | ||
const handleHide = () => { | ||
if (hideHasNeverBeenEmitted.value) { | ||
// If this is the first 'hide', which is emitted on page load, we un-do it. | ||
// This is because the CoreUI Sidebar component emits a 'hide' event on page load, which we | ||
// don't want to obey for larger screen sizes. | ||
resetSidebarPerScreenSize(); | ||
hideHasNeverBeenEmitted.value = false; | ||
} | ||
else { | ||
} else { | ||
// If this is not the first 'hide', emitted on page load, we obey it and sync | ||
// the parent component's value. | ||
visible.value = false; | ||
} | ||
} | ||
|
||
const breakpoint = 992; // CoreUI's "lg" breakpoint | ||
function resetSidebarPerScreenSize() { | ||
// Set the default values for the sidebar based on the screen size. | ||
if (window.innerWidth < breakpoint) { | ||
visible.value = false; | ||
largeScreen.value = false; | ||
} | ||
else { | ||
visible.value = true; | ||
largeScreen.value = true; | ||
} | ||
} | ||
}; | ||
|
||
onMounted(() => { | ||
window.addEventListener("resize", resetSidebarPerScreenSize); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copied from https://github.com/mrc-ide/packit/blob/main/db/bin/wait-for-db | ||
|
||
wait_for() | ||
{ | ||
echo "waiting up to $TIMEOUT seconds for postgres" | ||
start_ts=$(date +%s) | ||
for i in $(seq $TIMEOUT); do | ||
# Using pg_ready as: | ||
# | ||
# pg_isready -U $POSTGRES_USER -d $POSTGRES_DB | ||
# | ||
# seems heaps nicer but does not actually work properly | ||
# because it pulls us up to soon. | ||
psql -U $POSTGRES_USER -d $POSTGRES_DB -c "select 1;" > /dev/null 2>&1 | ||
result=$? | ||
if [[ $result -eq 0 ]]; then | ||
end_ts=$(date +%s) | ||
echo "postgres is available after $((end_ts - start_ts)) seconds" | ||
break | ||
fi | ||
sleep 1 | ||
echo "...still waiting" | ||
done | ||
return $result | ||
} | ||
|
||
# The variable expansion below is 100s by default, or the argument provided | ||
# to this script | ||
TIMEOUT="${1:-100}" | ||
wait_for | ||
RESULT=$? | ||
if [[ $RESULT -ne 0 ]]; then | ||
echo "postgres did not become available in time" | ||
fi | ||
exit $RESULT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is going to be used in multiple workflows, you might want to pull this out into a shared action, like these:
https://github.com/mrc-ide/packit/tree/05560383aef00035a62eae605094e016eb6bc03c/.github/actions/build-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll bear it in mind for if it gets used in more than two workflows!