Skip to content
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

feat: add environment-specific galaxy urls (#239) #241

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build Next.js Site
env:
NEXT_PUBLIC_BASE_PATH: ""
run: npm run build:local
run: npm run build:dev

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Build Next.js Site
env:
NEXT_PUBLIC_BASE_PATH: ""
run: npm run build:local
run: npm run build:prod

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
Expand Down
4 changes: 4 additions & 0 deletions app/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { setConfig } from "@databiosphere/findable-ui/lib/config/config";
import { SiteConfig } from "@databiosphere/findable-ui/lib/config/entities";
import brcAnalyticsDev from "../../site-config/brc-analytics/dev/config";
import brcAnalyticsLocal from "../../site-config/brc-analytics/local/config";
import brcAnalyticsProd from "../../site-config/brc-analytics/prod/config";

const CONFIGS: { [k: string]: SiteConfig } = {
"brc-analytics-dev": brcAnalyticsDev,
"brc-analytics-local": brcAnalyticsLocal,
"brc-analytics-prod": brcAnalyticsProd,
};

let appConfig: SiteConfig | null = null;
Expand Down
13 changes: 6 additions & 7 deletions app/utils/galaxy-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ky from "ky";
import { WORKFLOW_ID } from "../apis/catalog/brc-analytics-catalog/common/entities";
import { GALAXY_ENVIRONMENT } from "site-config/common/galaxy";

interface WorkflowLandingsBody {
public: true;
Expand All @@ -16,11 +17,9 @@ interface WorkflowLanding {
uuid: string;
}

const WORKFLOW_LANDINGS_API_URL =
"https://test.galaxyproject.org/api/workflow_landings";

const WORKFLOW_LANDING_URL_PREFIX =
"https://test.galaxyproject.org/workflow_landings/";
const { galaxyInstanceUrl } = GALAXY_ENVIRONMENT;
const workflowLandingsApiUrl = `${galaxyInstanceUrl}api/workflow_landings`;
const workflowLandingUrl = `${galaxyInstanceUrl}workflow_landings`;

/**
* Get the URL of the workflow landing page for the given genome workflow.
Expand All @@ -44,14 +43,14 @@ export async function getWorkflowLandingUrl(
workflow_id: workflowId,
workflow_target_type: "trs_url",
};
const res = await ky.post<WorkflowLanding>(WORKFLOW_LANDINGS_API_URL, {
const res = await ky.post<WorkflowLanding>(workflowLandingsApiUrl, {
json: body,
retry: {
methods: ["post"],
},
});
const id = (await res.json()).uuid;
return `${WORKFLOW_LANDING_URL_PREFIX}${encodeURIComponent(id)}?public=true`;
return `${workflowLandingUrl}/${encodeURIComponent(id)}?public=true`;
}

function buildFastaUrl(identifier: string): string {
Expand Down
2 changes: 1 addition & 1 deletion cc-brc-analytics.dev.clevercanary.com-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ npm ci
export NEXT_PUBLIC_BASE_PATH=""

# Build catalog
npm run build:local
npm run build:dev

export BUCKET=s3://tik-brc-analytics.dev/
export SRCDIR=out/
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"scripts": {
"dev": "./scripts/dev.sh brc-analytics && ./scripts/set-version.sh dev && next dev",
"build:local": "./scripts/build.sh brc-analytics local && ./scripts/set-version.sh && next build",
"build:dev": "./scripts/build.sh brc-analytics dev && ./scripts/set-version.sh && next build",
"build:prod": "./scripts/build.sh brc-analytics prod && ./scripts/set-version.sh && next build",
"start": "npx serve out",
"lint": "next lint --dir .",
"check-format": "prettier --check .",
Expand Down
2 changes: 1 addition & 1 deletion psu-brc-analytics.org-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ npm ci
export NEXT_PUBLIC_BASE_PATH=""

# Build catalog
npm run build:local
npm run build:prod

export BUCKET=s3://izk-brc-analytics.org/
export SRCDIR=out/
Expand Down
2 changes: 2 additions & 0 deletions site-config/brc-analytics/dev/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_SITE_CONFIG='brc-analytics-dev'
NEXT_PUBLIC_GALAXY_ENV="TEST"
8 changes: 8 additions & 0 deletions site-config/brc-analytics/dev/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SiteConfig } from "@databiosphere/findable-ui/lib/config/entities";
import { makeConfig } from "../local/config";

const BROWSER_URL = "https://brc-analytics.dev.clevercanary.com";

const config: SiteConfig = makeConfig(BROWSER_URL);

export default config;
1 change: 1 addition & 0 deletions site-config/brc-analytics/local/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_SITE_CONFIG='brc-analytics-local'
NEXT_PUBLIC_GALAXY_ENV="TEST"
7 changes: 5 additions & 2 deletions site-config/brc-analytics/local/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ const GIT_HUB_REPO_URL = "https://github.com/galaxyproject/brc-analytics";
*
* @returns site config.
*/
export function makeConfig(browserUrl: string, gitHubUrl: string): SiteConfig {
export function makeConfig(
browserUrl: string,
gitHubUrl = GIT_HUB_REPO_URL
): SiteConfig {
return {
appTitle: APP_TITLE,
browserURL: browserUrl,
Expand Down Expand Up @@ -89,6 +92,6 @@ export function makeConfig(browserUrl: string, gitHubUrl: string): SiteConfig {
};
}

const config: SiteConfig = makeConfig(BROWSER_URL, GIT_HUB_REPO_URL);
const config: SiteConfig = makeConfig(BROWSER_URL);

export default config;
2 changes: 2 additions & 0 deletions site-config/brc-analytics/prod/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_SITE_CONFIG='brc-analytics-prod'
NEXT_PUBLIC_GALAXY_ENV="PROD"
8 changes: 8 additions & 0 deletions site-config/brc-analytics/prod/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SiteConfig } from "@databiosphere/findable-ui/lib/config/entities";
import { makeConfig } from "../local/config";

const BROWSER_URL = "https://brc-analytics.org";

const config: SiteConfig = makeConfig(BROWSER_URL);

export default config;
12 changes: 12 additions & 0 deletions site-config/common/galaxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
interface GalaxyEnvironment {
galaxyInstanceUrl: string;
}

export const GALAXY_ENVIRONMENT: GalaxyEnvironment =
process.env.NEXT_PUBLIC_GALAXY_ENV === "PROD"
? {
galaxyInstanceUrl: "https://usegalaxy.org/",
}
: {
galaxyInstanceUrl: "https://test.galaxyproject.org/",
};