Skip to content

Commit 62bd94d

Browse files
Merge pull request #7 from Breeding-Insight/release/1.1.1
v1.2 Release
2 parents 7498f44 + 5029941 commit 62bd94d

File tree

5 files changed

+313
-28
lines changed

5 files changed

+313
-28
lines changed

.github/workflows/docker-build.yml

Lines changed: 114 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,146 @@ on:
66
- develop
77
- release/**
88
- brapi-server-v2
9-
9+
1010
workflow_dispatch:
11+
inputs:
12+
upstream_repo:
13+
description: 'Optional: Override upstream repository (owner/repo). Defaults to the repository this was forked from if not set.'
14+
required: false
15+
default: 'plantbreeding/brapi-Java-ProdServer'
16+
upstream_pr_number:
17+
description: 'Required if merging an upstream PR: PR number from the upstream repository to merge into develop for this build. ex: 11'
18+
required: false # Still false overall, but logic will require it if this feature is used.
19+
type: string
1120

1221
jobs:
1322
docker:
1423
runs-on: ubuntu-latest
1524

1625
steps:
17-
- uses: actions/checkout@v2
18-
26+
- name: Checkout branch
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0 # Fetch all history to ensure common ancestor is found
30+
31+
- name: Conditionally Fetch and Merge Upstream PR
32+
# This step runs if a PR number is provided AND (an upstream_repo input is given OR a parent repo full_name is available)
33+
if: |
34+
github.event.inputs.upstream_pr_number &&
35+
github.event.inputs.upstream_repo
36+
run: |
37+
UPSTREAM_REPO_SPECIFIED="${{ github.event.inputs.upstream_repo }}"
38+
UPSTREAM_PR_NUMBER="${{ github.event.inputs.upstream_pr_number }}"
39+
40+
if [[ -z "$UPSTREAM_PR_NUMBER" ]]; then
41+
echo "No upstream PR number provided. Skipping PR merge."
42+
exit 0
43+
fi
44+
45+
TARGET_UPSTREAM_REPO=""
46+
if [[ -n "$UPSTREAM_REPO_SPECIFIED" ]]; then
47+
TARGET_UPSTREAM_REPO="$UPSTREAM_REPO_SPECIFIED"
48+
echo "Using specified upstream repository: $TARGET_UPSTREAM_REPO"
49+
else
50+
echo "Error: Upstream PR number '$UPSTREAM_PR_NUMBER' was provided, but no upstream_repo was specified and parent repository could not be determined."
51+
exit 1
52+
fi
53+
54+
echo "Upstream PR to merge: $UPSTREAM_PR_NUMBER from $TARGET_UPSTREAM_REPO"
55+
UPSTREAM_REPO_URL="https://github.com/$TARGET_UPSTREAM_REPO.git"
56+
57+
# Fetch the PR from the upstream repository
58+
git fetch $UPSTREAM_REPO_URL +refs/pull/$UPSTREAM_PR_NUMBER/head:upstream_pr_branch
59+
60+
echo "Fetched PR branch 'upstream_pr_branch'. Merging into current HEAD (develop)..."
61+
# Merge the fetched PR branch. If conflicts occur, the script will exit with an error.
62+
git config user.name "GitHub Actions"
63+
git config user.email "actions@github.com"
64+
git merge upstream_pr_branch --no-ff -m "Merge upstream PR #$UPSTREAM_PR_NUMBER from $TARGET_UPSTREAM_REPO for testing"
65+
66+
echo "Merge complete."
67+
shell: bash
68+
1969
- name: Extract branch name
2070
shell: bash
21-
run: echo ::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})
71+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> "$GITHUB_OUTPUT"
2272
id: extract_branch
23-
24-
- run: git pull origin ${{steps.extract_branch.outputs.branch}}
25-
73+
74+
# This pull is no longer needed as checkout handles fetching the correct ref,
75+
# and the PR merge step brings in specific upstream changes.
76+
# - run: git pull origin ${{steps.extract_branch.outputs.branch}}
77+
2678
- name: Set up JDK 21
2779
uses: actions/setup-java@v4
2880
with:
2981
distribution: temurin
3082
java-version: '21'
3183
cache: maven
32-
84+
3385
- name: Build with Maven
3486
run: mvn clean install
3587

3688
- name: Set up Docker Buildx
37-
uses: docker/setup-buildx-action@v2
89+
uses: docker/setup-buildx-action@v3
3890
- name: Set up QEMU
39-
uses: docker/setup-qemu-action@v2
91+
uses: docker/setup-qemu-action@v3
4092
with:
41-
platforms: 'arm64,arm,amd64,amd'
42-
93+
platforms: 'arm64,arm,amd64'
94+
4395
- name: Login to Docker Hub
44-
uses: docker/login-action@v1
96+
uses: docker/login-action@v3
4597
with:
4698
username: ${{ secrets.DOCKERHUB_USERNAME }}
4799
password: ${{ secrets.DOCKERHUB_PASSWORD }}
48-
- name: Set tag
49-
id: vars
50-
run: echo ::set-output name=imageName::$(echo breedinginsight/brapi-java-server:${{ github.run_number }})
51-
52-
- name: Tag develop
53-
if: steps.extract_branch.outputs.branch == 'develop'
54-
run: echo "streamName=breedinginsight/brapi-java-server:develop" >> $GITHUB_ENV
55-
- name: Tag release candidate
56-
if: contains(github.ref, '/release/')
57-
run: echo "streamName=breedinginsight/brapi-java-server:rc" >> $GITHUB_ENV
58-
- name: Tag latest
59-
if: steps.extract_branch.outputs.branch == 'brapi-server-v2'
60-
run: echo "streamName=breedinginsight/brapi-java-server:latest" >> $GITHUB_ENV
100+
101+
- name: Determine Docker Tags
102+
id: docker_tags
103+
shell: bash
104+
run: |
105+
PR_NUMBER="${{ github.event.inputs.upstream_pr_number }}"
106+
IMAGE_BASE_NAME="breedinginsight/brapi-java-server"
107+
TAGS=""
108+
IS_PR_BUILD="false"
109+
110+
if [[ -n "$PR_NUMBER" ]]; then
111+
echo "This is a PR build. Setting PR-specific tag."
112+
PR_TAG="$IMAGE_BASE_NAME:pr-$PR_NUMBER"
113+
TAGS="$PR_TAG"
114+
IS_PR_BUILD="true"
115+
else
116+
echo "This is a regular build. Setting standard tags."
117+
RUN_NUMBER_TAG="$IMAGE_BASE_NAME:${{ github.run_number }}"
118+
TAGS="$RUN_NUMBER_TAG"
119+
120+
BRANCH_NAME="${{ steps.extract_branch.outputs.branch }}"
121+
STREAM_NAME=""
122+
if [[ "$BRANCH_NAME" == "develop" ]]; then
123+
STREAM_NAME="$IMAGE_BASE_NAME:develop"
124+
elif [[ "$BRANCH_NAME" == "brapi-server-v2" ]]; then # Assuming brapi-server-v2 is 'latest'
125+
STREAM_NAME="$IMAGE_BASE_NAME:latest"
126+
elif [[ "${{ github.ref }}" == refs/heads/release/* ]]; then
127+
STREAM_NAME="$IMAGE_BASE_NAME:rc"
128+
fi
129+
130+
if [[ -n "$STREAM_NAME" ]]; then
131+
TAGS="$TAGS,$STREAM_NAME" # Comma-separated for docker/build-push-action
132+
fi
133+
fi
134+
echo "Final tags: $TAGS"
135+
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
136+
echo "is_pr_build=$IS_PR_BUILD" >> "$GITHUB_OUTPUT"
137+
138+
# The original 'Set tag' and 'Tag develop/rc/latest' steps are now incorporated into 'Determine Docker Tags'
139+
# and are conditioned by is_pr_build logic within that step.
61140

62141
- name: Build Docker and push image
63142
run: |
64-
docker buildx build . --file Dockerfile --tag ${{steps.vars.outputs.imageName}} --tag ${{env.streamName}} --push --platform=linux/arm64,linux/amd64
143+
# Note: The `docker/build-push-action` is generally recommended over manual scripting
144+
# as it handles tags more robustly. However, to keep the change minimal,
145+
# this script adapts the original logic.
146+
FORMATTED_TAGS=""
147+
IFS=',' read -ra TAG_ARRAY <<< "${{ steps.docker_tags.outputs.tags }}"
148+
for tag in "${TAG_ARRAY[@]}"; do
149+
FORMATTED_TAGS="$FORMATTED_TAGS --tag $tag"
150+
done
151+
docker buildx build . --file Dockerfile $FORMATTED_TAGS --push --platform=linux/arm64,linux/amd64

src/main/java/org/brapi/test/BrAPITestServer/service/SearchQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class SearchQueryBuilder<T> {
2121

2222
public SearchQueryBuilder(Class<T> clazz) {
2323
this.selectClause = "SELECT distinct entity FROM " + clazz.getSimpleName() + " entity ";
24-
this.selectOnlyIds = "SELECT entity.id FROM " + clazz.getSimpleName() + " entity ";
24+
this.selectOnlyIds = "SELECT distinct entity.id FROM " + clazz.getSimpleName() + " entity ";
2525
this.whereClause = "WHERE 1=1 ";
2626
this.defaultSort = " ORDER BY entity.id ASC ";
2727
this.sortClause = "";
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
-- See the NOTICE file distributed with this work for additional information
2+
-- regarding copyright ownership.
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- http://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
16+
-- Updates trial.additional_info to have a datasets array instead of just observationDatasetId.
17+
-- Leaves observationDatasetId in place out of an abundance of caution.
18+
-- Only updates rows that don't already have datasets key (just in case the code was updated prematurely).
19+
DO
20+
$$
21+
BEGIN
22+
UPDATE
23+
trial
24+
SET
25+
additional_info = additional_info
26+
|| JSONB_BUILD_OBJECT(
27+
'datasets',
28+
JSONB_BUILD_ARRAY(
29+
JSONB_BUILD_OBJECT(
30+
'id', additional_info->'observationDatasetId',
31+
'name', additional_info->'defaultObservationLevel',
32+
'level', '0'
33+
)
34+
)
35+
)
36+
WHERE
37+
additional_info->'datasets' IS NULL;
38+
END
39+
$$;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
-- This migration updates existing list_item records based on DeltaBreed (Breeding Insight) specific fields.
3+
--
4+
-- These are the list types, the BJTS uses Java enums and stores ints in the database.
5+
-- 0: germplasm
6+
-- 1: markers
7+
-- 2: programs
8+
-- 3: trials
9+
-- 4: studies
10+
-- 5: observationUnits
11+
-- 6: observations
12+
-- 7: observationVariables
13+
-- 8: samples
14+
15+
DO
16+
$$
17+
BEGIN
18+
-- Update germplasm list items, the goal is to use the order defined by the listEntryNumbers.
19+
UPDATE
20+
list_item
21+
SET
22+
position = subquery.position
23+
FROM
24+
(
25+
SELECT
26+
-- Subtract 1 from row_number to get zero indexing.
27+
row_number() OVER (PARTITION BY li.list_id ORDER BY (g.additional_info->'listEntryNumbers'->>xr.external_reference_id::text)::int) - 1 AS position,
28+
li.id AS list_item_id
29+
FROM
30+
list_item li
31+
JOIN list l ON li.list_id = l.id
32+
JOIN list_external_references ler ON l.id = ler.list_entity_id
33+
JOIN external_reference xr ON xr.id = ler.external_references_id AND xr.external_reference_source = 'breedinginsight.org/lists'
34+
JOIN germplasm g ON li.item = g.germplasm_name
35+
WHERE
36+
l.list_type = 0 -- 0 is germplasm
37+
ORDER BY
38+
l.id
39+
) AS subquery
40+
WHERE
41+
list_item.id = subquery.list_item_id
42+
;
43+
44+
-- Update all non-germplasm list items. There is no existing order to preserve, assign sequential position values arbitrarily.
45+
UPDATE
46+
list_item
47+
SET
48+
position = subquery.position
49+
FROM
50+
(
51+
SELECT
52+
-- Subtract 1 from row_number to get zero indexing.
53+
row_number() OVER (PARTITION BY li.list_id) - 1 AS position,
54+
li.id AS list_item_id
55+
FROM
56+
list_item li
57+
JOIN list l ON li.list_id = l.id
58+
WHERE
59+
l.list_type != 0 -- 0 is germplasm, here we are addressing non-germplasm lists.
60+
ORDER BY
61+
l.id
62+
) AS subquery
63+
WHERE
64+
list_item.id = subquery.list_item_id
65+
;
66+
67+
END;
68+
$$;
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
-- Indexes for columns referenced by sync_list_related_tables_soft_deleted.
2+
CREATE INDEX IF NOT EXISTS list_external_references_list_id ON list_external_references (list_entity_id);
3+
CREATE INDEX IF NOT EXISTS list_item_list_id ON list_item (list_id);
4+
5+
-- Indexes for columns referenced by sync_sample_related_tables_soft_deleted.
6+
CREATE INDEX IF NOT EXISTS sample_external_references_sample_entity_id ON sample_external_references (sample_entity_id);
7+
CREATE INDEX IF NOT EXISTS vendor_file_sample_sample_dbid ON vendor_file_sample (sample_dbid);
8+
CREATE INDEX IF NOT EXISTS callset_sample_id ON callset (sample_id);
9+
10+
-- Indexes for columns referenced by sync_trial_related_tables_soft_deleted.
11+
CREATE INDEX IF NOT EXISTS trial_external_references_trial_entity_id ON trial_external_references (trial_entity_id);
12+
CREATE INDEX IF NOT EXISTS observation_unit_trial_id ON observation_unit (trial_id);
13+
CREATE INDEX IF NOT EXISTS trial_publication_trial_id ON trial_publication (trial_id);
14+
CREATE INDEX IF NOT EXISTS sample_trial_id ON sample (trial_id);
15+
CREATE INDEX IF NOT EXISTS study_trial_id ON study (trial_id);
16+
CREATE INDEX IF NOT EXISTS observation_trial_id ON observation (trial_id);
17+
CREATE INDEX IF NOT EXISTS trial_dataset_authorship_trial_id ON trial_dataset_authorship (trial_id);
18+
CREATE INDEX IF NOT EXISTS trial_contact_trial_db_id ON trial_contact (trial_db_id);
19+
CREATE INDEX IF NOT EXISTS plate_trial_id ON plate (trial_id);
20+
21+
-- Indexes for columns referenced by sync_germplasm_related_tables_soft_deleted.
22+
CREATE INDEX IF NOT EXISTS germplasm_external_references_germplasm_entity_id ON germplasm_external_references (germplasm_entity_id);
23+
CREATE INDEX IF NOT EXISTS germplasm_attribute_value_germplasm_id ON germplasm_attribute_value (germplasm_id);
24+
CREATE INDEX IF NOT EXISTS germplasm_donor_germplasm_id ON germplasm_donor (germplasm_id);
25+
-- The {table}_{column} naming convention would result in a name that is too long: germplasm_entity_type_of_germplasm_storage_code_germplasm_entity_id.
26+
CREATE INDEX IF NOT EXISTS germplasm_entity_id ON germplasm_entity_type_of_germplasm_storage_code (germplasm_entity_id);
27+
CREATE INDEX IF NOT EXISTS germplasm_institute_germplasm_id ON germplasm_institute (germplasm_id);
28+
CREATE INDEX IF NOT EXISTS germplasm_origin_germplasm_id ON germplasm_origin (germplasm_id);
29+
CREATE INDEX IF NOT EXISTS germplasm_search_results_germplasm_entity_id ON germplasm_search_results (germplasm_entity_id);
30+
CREATE INDEX IF NOT EXISTS germplasm_synonym_germplasm_id ON germplasm_synonym (germplasm_id);
31+
CREATE INDEX IF NOT EXISTS germplasm_taxon_germplasm_id ON germplasm_taxon (germplasm_id);
32+
CREATE INDEX IF NOT EXISTS pedigree_node_germplasm_id ON pedigree_node (germplasm_id);
33+
CREATE INDEX IF NOT EXISTS cross_parent_germplasm_id ON cross_parent (germplasm_id);
34+
CREATE INDEX IF NOT EXISTS observation_unit_germplasm_id ON observation_unit (germplasm_id);
35+
CREATE INDEX IF NOT EXISTS reference_set_source_germplasm_id ON reference_set (source_germplasm_id);
36+
CREATE INDEX IF NOT EXISTS seed_lot_content_mixture_germplasm_id ON seed_lot_content_mixture (germplasm_id);
37+
38+
-- Indexes for columns referenced by sync_germplasm_attribute_value_related_tables_soft_deleted.
39+
-- The {table}_{column} naming convention would result in a name that is too long: germplasm_attribute_value_external_references_germplasm_attribute_value_entity_id.
40+
CREATE INDEX IF NOT EXISTS germplasm_attribute_value_entity_id ON germplasm_attribute_value_external_references (germplasm_attribute_value_entity_id);
41+
42+
-- Indexes for columns referenced by sync_germplasm_donor_related_tables_soft_deleted.
43+
CREATE INDEX IF NOT EXISTS germplasm_donor_external_references_donor_entity_id ON germplasm_donor_external_references (donor_entity_id);
44+
45+
-- Indexes for columns referenced by sync_pedigree_node_related_tables_soft_deleted.
46+
CREATE INDEX IF NOT EXISTS pedigree_node_external_references_pedigree_node_entity_id ON pedigree_node_external_references (pedigree_node_entity_id);
47+
CREATE INDEX IF NOT EXISTS pedigree_edge_connected_node_id ON pedigree_edge (connected_node_id);
48+
CREATE INDEX IF NOT EXISTS pedigree_edge_this_node_id ON pedigree_edge (this_node_id);
49+
50+
-- Indexes for columns referenced by sync_pedigree_edge_related_tables_soft_deleted.
51+
CREATE INDEX IF NOT EXISTS pedigree_edge_external_references_pedigree_edge_entity_id ON pedigree_edge_external_references (pedigree_edge_entity_id);
52+
53+
-- Indexes for columns referenced by sync_observation_unit_related_tables_soft_deleted.
54+
CREATE INDEX IF NOT EXISTS observation_unit_external_references_observation_unit_entity_id ON observation_unit_external_references (observation_unit_entity_id);
55+
CREATE INDEX IF NOT EXISTS observation_observation_unit_id ON observation (observation_unit_id);
56+
CREATE INDEX IF NOT EXISTS observation_unit_level_observation_unit_id ON observation_unit_level (observation_unit_id);
57+
CREATE INDEX IF NOT EXISTS observation_unit_position_observation_unit_id ON observation_unit_position (observation_unit_id);
58+
CREATE INDEX IF NOT EXISTS observation_unit_treatment_observation_unit_id ON observation_unit_treatment (observation_unit_id);
59+
CREATE INDEX IF NOT EXISTS event_observation_units_observation_units_id ON event_observation_units (observation_units_id);
60+
CREATE INDEX IF NOT EXISTS image_observation_unit_id ON image (observation_unit_id);
61+
62+
-- Indexes for columns referenced by sync_image_related_tables_soft_deleted.
63+
CREATE INDEX IF NOT EXISTS image_entity_descriptive_ontology_terms_image_entity_id ON image_entity_descriptive_ontology_terms (image_entity_id);
64+
CREATE INDEX IF NOT EXISTS image_external_references_image_entity_id ON image_external_references (image_entity_id);
65+
CREATE INDEX IF NOT EXISTS image_observations_image_entity_id ON image_observations (image_entity_id);
66+
67+
-- Indexes for columns referenced by sync_reference_set_related_tables_soft_deleted.
68+
CREATE INDEX IF NOT EXISTS reference_set_external_references_reference_set_entity_id ON reference_set_external_references (reference_set_entity_id);
69+
CREATE INDEX IF NOT EXISTS reference_reference_set_id ON reference (reference_set_id);
70+
CREATE INDEX IF NOT EXISTS variant_reference_set_id ON variant (reference_set_id);
71+
CREATE INDEX IF NOT EXISTS variantset_reference_set_id ON variantset (reference_set_id);
72+
73+
-- Indexes for columns referenced by sync_reference_related_tables_soft_deleted.
74+
CREATE INDEX IF NOT EXISTS reference_bases_reference_id ON reference_bases (reference_id);
75+
CREATE INDEX IF NOT EXISTS reference_external_references_reference_entity_id ON reference_external_references (reference_entity_id);
76+
77+
-- Indexes for columns referenced by sync_reference_bases_related_tables_soft_deleted.
78+
-- The {table}_{column} naming convention would result in a name that is too long: reference_bases_external_references_reference_bases_page_entity_id.
79+
CREATE INDEX IF NOT EXISTS reference_bases_page_entity_id ON reference_bases_external_references (reference_bases_page_entity_id);
80+
81+
-- Indexes for columns referenced by sync_variant_related_tables_soft_deleted.
82+
CREATE INDEX IF NOT EXISTS variant_external_references_variant_entity_id ON variant_external_references (variant_entity_id);
83+
CREATE INDEX IF NOT EXISTS variant_entity_alternate_bases_variant_entity_id ON variant_entity_alternate_bases (variant_entity_id);
84+
CREATE INDEX IF NOT EXISTS variant_entity_ciend_variant_entity_id ON variant_entity_ciend (variant_entity_id);
85+
CREATE INDEX IF NOT EXISTS variant_entity_cipos_variant_entity_id ON variant_entity_cipos (variant_entity_id);
86+
CREATE INDEX IF NOT EXISTS variant_entity_filters_failed_variant_entity_id ON variant_entity_filters_failed (variant_entity_id);
87+
88+
-- Indexes for columns referenced by sync_variantset_related_tables_soft_deleted.
89+
CREATE INDEX IF NOT EXISTS variantset_analysis_variant_set_id ON variantset_analysis (variant_set_id);
90+
CREATE INDEX IF NOT EXISTS variantset_external_references_variant_set_entity_id ON variantset_external_references (variant_set_entity_id);
91+
CREATE INDEX IF NOT EXISTS variantset_format_variant_set_id ON variantset_format (variant_set_id);

0 commit comments

Comments
 (0)