Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b4eedf7
Add rendered dashboard skeleton
AlexAxthelm Dec 4, 2024
97f6373
Add Dashboard skeleton and function to copy to output dir
AlexAxthelm Dec 4, 2024
4810078
Increment version number to 0.0.0.9003
AlexAxthelm Dec 4, 2024
5f3abf7
Remove Dashboard skeleton from package
AlexAxthelm Dec 5, 2024
d8b5fa7
Add dashboard files to docker image
AlexAxthelm Dec 6, 2024
bc31c19
Add fucntion to copy dashboard files to output dir
AlexAxthelm Dec 6, 2024
1d23ff6
Add docker build and gh-pages workflows
AlexAxthelm Dec 6, 2024
e5a1220
Merge branch 'main' into feat/33-integrate-dashboard
AlexAxthelm Dec 6, 2024
069492b
Use hotifx branch of build action
AlexAxthelm Dec 6, 2024
ea9b622
Trigger CI
AlexAxthelm Dec 6, 2024
a0b41c2
Trigger CI
AlexAxthelm Dec 6, 2024
8f1b3f1
Use main branch of actions - after patch
AlexAxthelm Dec 6, 2024
5956743
Hadolint
AlexAxthelm Dec 6, 2024
da4445f
Grant write permissions to `id-token` (Azure Login)
AlexAxthelm Dec 9, 2024
1e6252f
fix: Pass absolute path to docker volume bind
AlexAxthelm Dec 9, 2024
5d8d5ed
add step to move files to expected directory
AlexAxthelm Dec 9, 2024
8712573
disable zip output
AlexAxthelm Dec 9, 2024
f2c94ab
fix: deploy correct output directoryu
AlexAxthelm Dec 9, 2024
6ee5b51
Checkout repor for GH pages deploy
AlexAxthelm Dec 9, 2024
9068b76
Move checkout step to beginning
AlexAxthelm Dec 9, 2024
2b43c5a
Chmod output dir
AlexAxthelm Dec 9, 2024
dd7ceaa
Change owner of output dir as well
AlexAxthelm Dec 9, 2024
d20ce43
Chmod as part of docker step, not after
AlexAxthelm Dec 9, 2024
2ae1274
Actually run docker image as GH user
AlexAxthelm Dec 9, 2024
7215492
Give action permissions to write to repo
AlexAxthelm Dec 9, 2024
458a445
Grant write permissions for PR (comment)
AlexAxthelm Dec 9, 2024
12df8a4
Trigger CI
AlexAxthelm Dec 9, 2024
cdb8034
remove chmod 777 command
AlexAxthelm Dec 9, 2024
b7fcf84
Use main branch of Dashboard source
AlexAxthelm Dec 9, 2024
de6babd
Remove commented code
AlexAxthelm Dec 9, 2024
485f8f8
Rename envvar
AlexAxthelm Dec 9, 2024
cee26cc
remove commented code
AlexAxthelm Dec 9, 2024
c5da0ac
Trigger CI
AlexAxthelm Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
^LICENSE\.md$
^\.Rproj\.user$
^docker-compose.yml$
^dashboard_output_dir
30 changes: 30 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
push:
branches: [main]
schedule:
- cron: '0 0 * * 1,2,3,4,5'
workflow_dispatch:

name: docker

jobs:
docker:
name: Docker actions
uses: RMI-PACTA/actions/.github/workflows/docker.yml@main
with:
do-check-r-sysdeps: false

gh-pages:
name: gh-pages
uses: ./.github/workflows/gh-pages.yml
needs: [docker]
secrets: inherit
with:
full-image-name: ${{ needs.docker.outputs.full-image-name }}
109 changes: 109 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Deploy to GitHub Pages

on:
workflow_call:
inputs:
full-image-name:
required: true
type: string

concurrency: preview-${{ github.ref }}

jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:

- name: Checkout
uses: actions/checkout@v3

# https://github.com/Azure/login?tab=readme-ov-file#login-with-openid-connect-oidc-recommended
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Download Analysis Outputs
id: download-analysis-outputs
uses: RMI-PACTA/actions/actions/azure/blob-copy@main
with:
source: https://pactadatadev.blob.core.windows.net/ghactions-workflow-pacta-results/main/latest/full_params_2023Q4/analysis_output_dir
destination: tmp_analysis_output_dir

- name: Download Benchmarks
id: download-benchmarks
uses: RMI-PACTA/actions/actions/azure/blob-copy@main
with:
source: https://pactadatadev.blob.core.windows.net/benchmarks-webapp/2023Q4/2023Q4_20240529T002355Z
destination: tmp_benchmarks_dir

- name: move output and analysis files to correct directory
run: |
mv tmp_analysis_output_dir/main/latest/full_params_2023Q4/analysis_output_dir analysis_output_dir
ls analysis_output_dir
mv tmp_benchmarks_dir/2023Q4/2023Q4_20240529T002355Z benchmarks_dir
ls benchmarks_dir

- name: Create Output Directories
run: |
mkdir -p dashboard_output_dir/data

- name: Run Docker Image
env:
FULL_IMAGE_NAME: ${{ inputs.full-image-name }}
WORKSPACE: ${{ github.workspace }}
PARAMETERS: ""
ANALYSIS_OUTPUT_DIR: "analysis_output_dir"
BENCHMARKS_DIR: "benchmarks_dir"
DASHBOARD_DATA_DIR: "dashboard_output_dir/data"
DASHBOARD_OUTPUT_DIR: "dashboard_output_dir"
run: |

docker run \
--network none \
--user $(id -u):$(id -g) \
--env LOG_LEVEL=TRACE \
--env ANALYSIS_OUTPUT_DIR="/mnt/analysis_output_dir" \
--env BENCHMARKS_DIR="/mnt/benchmarks_dir" \
--env DASHBOARD_DATA_DIR="/mnt/dashboard_output_dir/data" \
--env DASHBOARD_OUTPUT_DIR="/mnt/dashboard_output_dir" \
--mount type=bind,readonly,source=${WORKSPACE}/${BENCHMARKS_DIR},target=/mnt/benchmarks_dir \
--mount type=bind,source=${WORKSPACE}/${ANALYSIS_OUTPUT_DIR},target=/mnt/analysis_output_dir \
--mount type=bind,source=${WORKSPACE}/${DASHBOARD_OUTPUT_DIR},target=/mnt/dashboard_output_dir \
--mount type=bind,source=${WORKSPACE}/${DASHBOARD_DATA_DIR},target=/mnt/dashboard_output_dir/data \
$FULL_IMAGE_NAME \
"$PARAMETERS"

- name: chmod & List outputs
run: |
ls -lR dashboard_output_dir

- name: Add nojekyll file
if: github.event.action != 'closed'
run: touch dashboard_output_dir/.nojekyll

- name: 🚀 Deploy main page
if: ${{ github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dashboard_output_dir # The folder the action should deploy.
clean: true
force: false
clean-exclude: |
.nojekyll
pr-preview/

- name: 🛸 Deploy PR preview
if: ${{ github.event_name == 'pull_request' }}
uses: rossjrw/pr-preview-action@v1
with:
source-dir: dashboard_output_dir
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.Rhistory
analysis_output_dir/**/*
benchmarks_dir/**/*
dashboard_data_dir/**/*
dashboard_output_dir/**/*
!dashboard_output_dir/data/.gitkeep
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: workflow.pacta.dashboard
Title: Run PACTA dashboard JSON generation
Version: 0.0.0.9004
Version: 0.0.0.9005
Authors@R:
c(person(given = "Alex",
family = "Axthelm",
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ RUN CRAN_LIKE_URL="https://packagemanager.posit.co/cran/__linux__/jammy/2024-04-
RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" \
apt-get install -y --no-install-recommends \
git=1:2.34.*
git=1:2.34.* \
&& chmod -R a+rwX /root \
&& rm -rf /var/lib/apt/lists/*

# install pak
RUN Rscript -e "install.packages('pak', repos = 'https://r-lib.github.io/p/pak/stable/')"
Expand All @@ -21,6 +23,9 @@ RUN Rscript -e "pak::local_install_deps('/workflow.pacta.dashboard')"

FROM base AS install-pacta

ENV DASHBOARD_SKELETON_FILES_DIR="/mnt/dashboard_skeleton_files"
COPY --from=ghcr.io/rmi-pacta/pacta-dashboard-svelte:main /app/build $DASHBOARD_SKELETON_FILES_DIR/

COPY . /workflow.pacta.dashboard/

RUN Rscript -e "pak::local_install(root = '/workflow.pacta.dashboard')"
Expand Down
33 changes: 33 additions & 0 deletions R/build_dashboard.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
build_dashboard <- function(
params,
analysis_output_dir = Sys.getenv("ANALYSIS_OUTPUT_DIR"),
benchmarks_dir = Sys.getenv("BENCHMARKS_DIR"),
dashboard_data_dir = Sys.getenv("DASHBOARD_DATA_DIR"),
dashboard_skeleton_files_dir = Sys.getenv("DASHBOARD_SKELETON_FILES_DIR"),
dashboard_output_dir = Sys.getenv("DASHBOARD_OUTPUT_DIR")
) {

prepare_pacta_dashboard_data(
analysis_output_dir = analysis_output_dir,
dashboard_data_dir = dashboard_data_dir,
benchmarks_dir = benchmarks_dir
)

Check warning on line 14 in R/build_dashboard.R

View check run for this annotation

Codecov / codecov/patch

R/build_dashboard.R#L10-L14

Added lines #L10 - L14 were not covered by tests

dashboard_copy_success <- copy_dashboard_files(
dashboard_skeleton_files_dir = dashboard_skeleton_files_dir,
dashboard_output_dir = dashboard_output_dir
)

Check warning on line 19 in R/build_dashboard.R

View check run for this annotation

Codecov / codecov/patch

R/build_dashboard.R#L16-L19

Added lines #L16 - L19 were not covered by tests

dashboard_output_data_dir <- file.path(dashboard_output_dir, "data")
if (dashboard_data_dir != dashboard_output_data_dir) {
if (!dir.exists(dashboard_output_data_dir)) {
dir.create(dashboard_output_data_dir, recursive = TRUE)

Check warning on line 24 in R/build_dashboard.R

View check run for this annotation

Codecov / codecov/patch

R/build_dashboard.R#L21-L24

Added lines #L21 - L24 were not covered by tests
}
data_copy_success <- file.copy(
from = dashboard_data_dir,
to = dashboard_output_data_dir,
recursive = TRUE
)

Check warning on line 30 in R/build_dashboard.R

View check run for this annotation

Codecov / codecov/patch

R/build_dashboard.R#L26-L30

Added lines #L26 - L30 were not covered by tests
}

}
19 changes: 19 additions & 0 deletions R/copy_dashboard_files.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
copy_dashboard_files <- function(
dashboard_skeleton_files_dir = Sys.getenv("DASHBOARD_SKELETON_FILES_DIR"),
dashboard_output_dir = Sys.getenv("DASHBOARD_OUTPUT_DIR")
) {

dashboard_files <- list.files(
dashboard_skeleton_files_dir,
full.names = TRUE,
recursive = FALSE
)

Check warning on line 10 in R/copy_dashboard_files.R

View check run for this annotation

Codecov / codecov/patch

R/copy_dashboard_files.R#L6-L10

Added lines #L6 - L10 were not covered by tests

dashboard_copy_success <- file.copy(
from = dashboard_files,
to = file.path(dashboard_output_dir),
recursive = TRUE
)

Check warning on line 16 in R/copy_dashboard_files.R

View check run for this annotation

Codecov / codecov/patch

R/copy_dashboard_files.R#L12-L16

Added lines #L12 - L16 were not covered by tests

return(all(dashboard_copy_success))

Check warning on line 18 in R/copy_dashboard_files.R

View check run for this annotation

Codecov / codecov/patch

R/copy_dashboard_files.R#L18

Added line #L18 was not covered by tests
}
3 changes: 2 additions & 1 deletion R/prepare_pacta_dashboard_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ prep_key_bars_portfolio(


# put JSON and CSV outputs into a zip archive ----------------------------------
zip_outputs(output_dir)

# zip_outputs(output_dir)

}

Expand Down
24 changes: 21 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ services:
LOG_LEVEL: TRACE
ANALYSIS_OUTPUT_DIR: "/mnt/analysis_output_dir"
BENCHMARKS_DIR: "/mnt/benchmarks_dir"
DASHBOARD_DATA_DIR: "/mnt/dashboard_data_dir"
DASHBOARD_DATA_DIR: "/mnt/dashboard_output_dir/data"
DASHBOARD_OUTPUT_DIR: "/mnt/dashboard_output_dir"
volumes:
- type: bind
source: ${benchmarks_dir:-./benchmarks_dir}
Expand All @@ -22,6 +23,23 @@ services:
target: /mnt/analysis_output_dir
read_only: true
- type: bind
source: ${dashboard_data_dir:-./dashboard_data_dir}
target: /mnt/dashboard_data_dir
source: ${dashboard_data_dir:-./dashboard_output_dir/data}
target: /mnt/dashboard_output_dir/data
read_only: false
- type: bind
source: ${dashboard_output_dir:-./dashboard_output_dir}
target: /mnt/dashboard_output_dir
read_only: false

server:
image: nginx:alpine
ports:
- 3000:80
volumes:
- type: bind
source: ${dashboard_output_dir:-./dashboard_output_dir}
target: /usr/share/nginx/html
read_only: false
depends_on:
workflow.pacta.dashboard:
condition: service_completed_successfully # build-app acts as an init container
2 changes: 1 addition & 1 deletion inst/extdata/scripts/prepare_dashboard_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# force_array = c("portfolio", "files")
# )

manifest_info <- workflow.pacta.dashboard:::prepare_pacta_dashboard_data(
manifest_info <- workflow.pacta.dashboard:::build_dashboard(
# params = params
)

Expand Down
Loading