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

TASK-6399 - CI/CD: Include save reports option for tasks workflows #2477

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
38 changes: 28 additions & 10 deletions .github/workflows/pull-request-approved.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
name: Pull request approve workflow
run-name: 'Pull request approve workflow ${{ github.event.pull_request.head.ref }} -> ${{ github.event.pull_request.base.ref }} by @${{ github.actor }}'

on:
pull_request_review:
types: [submitted]
types: [ submitted ]

jobs:
build:
uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop
with:
maven_opts: -Phdp3.1,RClient -Dopencga.war.name=opencga -Dcheckstyle.skip
calculate-xetabase-branch:
name: Calculate Xetabase branch
runs-on: ubuntu-22.04
outputs:
xetabase_branch: ${{ steps.get_xetabase_branch.outputs.xetabase_branch }}
steps:
- name: Clone java-common-libs
uses: actions/checkout@v4
with:
fetch-depth: '10'
- id: get_xetabase_branch
name: "Get current branch for Xetabase from target branch"
run: |
chmod +x ./.github/workflows/scripts/xetabase-branch.sh
ls ./.github/workflows/scripts/
ls ./.github/workflows/
bash --version
xetabase_branch=$(./.github/workflows/scripts/xetabase-branch.sh ${{ github.event.pull_request.base.ref }})
echo "__Xetabase ref:__ \"${xetabase_branch}\"" | tee -a ${GITHUB_STEP_SUMMARY}
echo "xetabase_branch=${xetabase_branch}" >> $GITHUB_OUTPUT

test:
name: "Run all tests before merging, ie. short, medium and long tests."
uses: ./.github/workflows/test-analysis.yml
needs: build
name: "Run all tests before merging"
needs: calculate-xetabase-branch
uses: opencb/java-common-libs/.github/workflows/test-xetabase-workflow.yml@TASK-6399
with:
test_profile: runShortTests,runMediumTests,runLongTests
secrets: inherit
branch: ${{ needs.calculate-xetabase-branch.outputs.xetabase_branch }}
task: ${{ github.event.pull_request.head.ref }}
secrets: inherit
42 changes: 42 additions & 0 deletions .github/workflows/scripts/xetabase-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Function to calculate the corresponding branch of Xetabase project
get_xetabase_branch() {
# Input parameter (branch name)
input_branch="$1"

# Check if the branch name is "develop" in that case return the same branch name
if [[ "$input_branch" == "develop" ]]; then
echo "develop"
return 0
fi

# Check if the branch name starts with "release-" and follows the patterns "release-a.b.x" or "release-a.b.c.x"
if [[ "$input_branch" =~ ^release-([0-9]+)\.([0-9]+)\.x$ ]] || [[ "$input_branch" =~ ^release-([0-9]+)\.([0-9]+)\.([0-9]+)\.x$ ]]; then
# Extract the MAJOR part of the branch name
MAJOR=${BASH_REMATCH[1]}
# Calculate the XETABASE_MAJOR by subtracting 3 from MAJOR
XETABASE_MAJOR=$((MAJOR - 3))
# Check if the XETABASE_MAJOR is negative
if (( XETABASE_MAJOR < 0 )); then
echo "Error: 'MAJOR' digit after subtraction results in a negative number."
return 1
fi
# Construct and echo the new branch name
echo "release-$XETABASE_MAJOR.${input_branch#release-$MAJOR.}"
return 0
fi

# If the branch name does not match any of the expected patterns
echo "Error: The branch name is not correct."
return 1
}

# Check if the script receives exactly one argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <branch-name>"
exit 1
fi

# Call the function with the input branch name
get_xetabase_branch "$1"
Loading