Skip to content

Commit

Permalink
Update main_v5.1-ref after dtcenter/MET#2960 (#2683)
Browse files Browse the repository at this point in the history
* added new use case that was missing

* Bugfix #2279 main_v5.1 - buoy station file from 2022 (#2281)

* Fix typo in pull_request_template.md

* added notes to make it clear that upgrade instructions are not needed if upgrading from 5.0 to 5.1

* New issue template: Update Truth (#2332)

Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
(cherry picked from commit 44335f3)

* add GitHub Actions workflow that is used to create Docker images that hold the conda environment used for the automated tests -- adding this to the default main_v5.1 branch so that it will become available to run for other branches as a workflow_dispatch workflow

* add argument to workflow dispatch event so that MET DockerHub repo used for tests can be easily overridden to test changes in a MET PR before merging

* Feature dtcenter/MET#2796 main_v5.1 GHA Node20 deprecation warnings (#2474)

* per dtcenter/MET#2796, update versions of actions to prevent deprecated node warnings in GHA runs - main_v5.1

* fix ReadTheDocs requirements to include pillow which is a dependency of sphinx-gallery: see https://blog.readthedocs.com/defaulting-latest-build-tools/ for more info on why this was necessary

* install python packages via apk instead of pip to prevent GHA failures that were fixed in develop but not in main_v5.1

* per dtcenter/MET#2796, fix error log merging for main_v5.1 same as develop

* Bump pillow from 10.0.1 to 10.2.0 in /docs (#2477)

Bumps [pillow](https://github.com/python-pillow/Pillow) from 10.0.1 to 10.2.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](python-pillow/Pillow@10.0.1...10.2.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Create 5.1.0_casper

* Update update_truth.md

Fix typo in the update_truth issue template.

* Update update_truth.md

Clarify wording on the update_truth issue template.

* Feature #2537 main_v5.1 sonarqube_gha (#2542)

* Per #2537, add SonarQube workflow for METplus

* Per #2537, update nightly build email list.

* Per #2537, fix cut/paste error configure_sonarqube.sh

* Per #2537, exclude test code from code coverage statistics.

* update link to METplus Components Python Requirements table in PR template

* update pillow version based on recommendation from dependabot: https://github.com/dtcenter/METplus/security/dependabot/5

* Fix main_v5.1 GHA - disk space and METviewer version (#2561)

* added more commands to free up disk space as suggested in https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh, ci-run-all-cases

* update location of METviewer docker-compose.yml file that moved from PR dtcenter/METviewer#525

* turn on use cases to test

* use main_v5.1 tag of METviewer on DockerHub

* turn off use case groups after confirming that they now run successfully

* Feature #2537 main_v5.1 single_sq_project (#2559)

* Feature 2346 main v5.1 update templates (#2588)

* Per #2346, modifying issue templates

* Per #2346, modifying the pull request template

* Per #2346, modifying entries based on suggestions by @georgemccabe

* Feature 2346 main v5.1 update templates (#2595)

* Per #2346, modifying issue templates

* Per #2346, modifying the pull request template

* Per #2346, modifying entries based on suggestions by @georgemccabe

* Per 2346, making updates based on feedback at last MET Eng. Meeting

* fix broken link

* Bump certifi from 2023.7.22 to 2024.7.4 (#2632)

Bumps [certifi](https://github.com/certifi/python-certifi) from 2023.7.22 to 2024.7.4.
- [Commits](certifi/python-certifi@2023.07.22...2024.07.04)

---
updated-dependencies:
- dependency-name: certifi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* main_v5.1 - Enhance update truth data workflow to create a uniquely named branch... (#2678)

* Enhance update truth data workflow to create a uniquely named branch to update *-ref branches and commit/append to a log file that tracks the reasons for updating the truth data. This is done to ensure that the *-ref branch testing workflow run that actually updates the truth data is always run even if there are no other changes to the METplus branch since the last update, e.g. when a change to another component like MET warrants the truth data update

* git add change log file in case it doesn't already exist

* changed logic to no longer push changes to develop/main_vX.Y, but instead merge changes from -ref into the update branch

* retain update truth history file from *-ref

* prevent failure when changelog does not exist in -ref branch

* added entry to update truth change log: main_v5.1 dtcenter/MET#2960

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>
Co-authored-by: John Halley Gotway <johnhg@ucar.edu>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Julie Prestopnik <jpresto@ucar.edu>
Co-authored-by: metplus-bot <97135045+metplus-bot@users.noreply.github.com>
  • Loading branch information
6 people committed Sep 9, 2024
1 parent 38aa827 commit 5efcdc2
Show file tree
Hide file tree
Showing 31 changed files with 879 additions and 198 deletions.
19 changes: 11 additions & 8 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ Describe the steps to reproduce the behavior:
- [ ] Select **scientist(s)** or **no scientist** required

### Labels ###
- [ ] Review default **alert** labels
- [ ] Select **component(s)**
- [ ] Select **priority**
- [ ] Select **requestor(s)**

### Projects and Milestone ###
- [ ] Select **Organization** level **Project** for support of the current coordinated release
- [ ] Select **Repository** level **Project** for development toward the next official release or add **alert: NEED CYCLE ASSIGNMENT** label
### Milestone and Projects ###
- [ ] Select **Milestone** as the next bugfix version
- [ ] Select **Coordinated METplus-X.Y Support** project for support of the current coordinated release
- [ ] Select **METplus-Wrappers-X.Y.Z Development** project for development toward the next official release

## Define Related Issue(s) ##
Consider the impact to the other METplus components.
- [ ] [METplus](https://github.com/dtcenter/METplus/issues/new/choose), [MET](https://github.com/dtcenter/MET/issues/new/choose), [METdataio](https://github.com/dtcenter/METdataio/issues/new/choose), [METviewer](https://github.com/dtcenter/METviewer/issues/new/choose), [METexpress](https://github.com/dtcenter/METexpress/issues/new/choose), [METcalcpy](https://github.com/dtcenter/METcalcpy/issues/new/choose), [METplotpy](https://github.com/dtcenter/METplotpy/issues/new/choose)


## Bugfix Checklist ##
See the [METplus Workflow](https://metplus.readthedocs.io/en/latest/Contributors_Guide/github_workflow.html) for details.
- [ ] Complete the issue definition above, including the **Time Estimate** and **Funding Source**.
Expand All @@ -65,20 +67,21 @@ Branch name: `bugfix_<Issue Number>_main_<Version>_<Description>`
- [ ] Add/update log messages for easier debugging.
- [ ] Add/update unit tests.
- [ ] Add/update documentation.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/overview.html#metplus-components-python-requirements) table.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/appendixA.html#metplus-components-python-packages) table.
- [ ] Push local changes to GitHub.
- [ ] Submit a pull request to merge into **main_\<Version>**.
Pull request: `bugfix <Issue Number> main_<Version> <Description>`
- [ ] Define the pull request metadata, as permissions allow.
Select: **Reviewer(s)** and **Development** issues
Select: **Organization** level software support **Project** for the current coordinated release
Select: **Reviewer(s)** and **Development** issue
Select: **Milestone** as the next bugfix version
Select: Coordinated METplus-X.Y Support project for support of the current coordinated release
- [ ] Iterate until the reviewer(s) accept and merge your changes.
- [ ] Delete your fork or branch.
- [ ] Complete the steps above to fix the bug on the **develop** branch.
Branch name: `bugfix_<Issue Number>_develop_<Description>`
Pull request: `bugfix <Issue Number> develop <Description>`
Select: **Reviewer(s)** and **Development** issues
Select: **Repository** level development cycle **Project** for the next official release
Select: **Reviewer(s)** and **Development** issue
Select: **Milestone** as the next official version
Select: **METplus-Wrappers-X.Y.Z Development** project for development toward the next official release

- [ ] Close this issue.
14 changes: 8 additions & 6 deletions .github/ISSUE_TEMPLATE/enhancement_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ Consider breaking the enhancement down into sub-issues.
- [ ] Select **scientist(s)** or **no scientist** required

### Labels ###
- [ ] Review default **alert** labels
- [ ] Select **component(s)**
- [ ] Select **priority**
- [ ] Select **requestor(s)**

### Projects and Milestone ###
- [ ] Select **Repository** and/or **Organization** level **Project(s)** or add **alert: NEED CYCLE ASSIGNMENT** label
- [ ] Select **Milestone** as the next official version or **Future Versions**
### Milestone and Projects ###
- [ ] Select **Milestone** as a **METplus-Wrappers-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas**
- [ ] For a **METplus-Wrappers-X.Y.Z** version, select the **METplus-Wrappers-X.Y.Z Development** project

## Define Related Issue(s) ##
Consider the impact to the other METplus components.
Expand All @@ -54,14 +55,15 @@ Branch name: `feature_<Issue Number>_<Description>`
- [ ] Add/update log messages for easier debugging.
- [ ] Add/update unit tests.
- [ ] Add/update documentation.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/overview.html#metplus-components-python-requirements) table.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/appendixA.html#metplus-components-python-packages) table.
- [ ] For any new datasets, an entry to the [METplus Verification Datasets Guide](https://metplus.readthedocs.io/en/latest/Verification_Datasets/index.html).
- [ ] Push local changes to GitHub.
- [ ] Submit a pull request to merge into **develop**.
Pull request: `feature <Issue Number> <Description>`
- [ ] Define the pull request metadata, as permissions allow.
Select: **Reviewer(s)** and **Development** issues
Select: **Repository** level development cycle **Project** for the next official release
Select: **Reviewer(s)** and **Development** issue
Select: **Milestone** as the next official version
Select: **METplus-Wrappers-X.Y.Z Development** project for development toward the next official release
- [ ] Iterate until the reviewer(s) accept and merge your changes.
- [ ] Delete your fork or branch.
- [ ] Close this issue.
14 changes: 8 additions & 6 deletions .github/ISSUE_TEMPLATE/new_feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ Consider breaking the new feature down into sub-issues.
- [ ] Select **scientist(s)** or **no scientist** required

### Labels ###
- [ ] Review default **alert** labels
- [ ] Select **component(s)**
- [ ] Select **priority**
- [ ] Select **requestor(s)**

### Projects and Milestone ###
- [ ] Select **Repository** and/or **Organization** level **Project(s)** or add **alert: NEED CYCLE ASSIGNMENT** label
- [ ] Select **Milestone** as the next official version or **Future Versions**
### Milestone and Projects ###
- [ ] Select **Milestone** as a **METplus-Wrappers-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas**
- [ ] For a **METplus-Wrappers-X.Y.Z** version, select the **METplus-Wrappers-X.Y.Z Development** project

## Define Related Issue(s) ##
Consider the impact to the other METplus components.
Expand All @@ -58,14 +59,15 @@ Branch name: `feature_<Issue Number>_<Description>`
- [ ] Add/update log messages for easier debugging.
- [ ] Add/update unit tests.
- [ ] Add/update documentation.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/overview.html#metplus-components-python-requirements) table.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/appendixA.html#metplus-components-python-packages) table.
- [ ] For any new datasets, an entry to the [METplus Verification Datasets Guide](https://metplus.readthedocs.io/en/latest/Verification_Datasets/index.html).
- [ ] Push local changes to GitHub.
- [ ] Submit a pull request to merge into **develop**.
Pull request: `feature <Issue Number> <Description>`
- [ ] Define the pull request metadata, as permissions allow.
Select: **Reviewer(s)** and **Development** issues
Select: **Repository** level development cycle **Project** for the next official release
Select: **Reviewer(s)** and **Development** issue
Select: **Milestone** as the next official version
Select: **METplus-Wrappers-X.Y.Z Development** project for development toward the next official release
- [ ] Iterate until the reviewer(s) accept and merge your changes.
- [ ] Delete your fork or branch.
- [ ] Close this issue.
14 changes: 8 additions & 6 deletions .github/ISSUE_TEMPLATE/new_use_case.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ Consider breaking the new feature down into sub-issues.
- [ ] Select **scientist(s)** or **no scientist** required

### Labels ###
- [ ] Review default **alert** labels
- [ ] Select **component(s)**
- [ ] Select **priority**
- [ ] Select **requestor(s)**
- [ ] Select **privacy**

### Projects and Milestone ###
- [ ] Select **Repository** and/or **Organization** level **Project(s)** or add **alert: NEED CYCLE ASSIGNMENT** label
- [ ] Select **Milestone** as the next official version or **Future Versions**
### Milestone and Projects ###
- [ ] Select **Milestone** as a **METplus-Wrappers-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas**
- [ ] For a **METplus-Wrappers-X.Y.Z** version, select the **METplus-Wrappers-X.Y.Z Development** project

## Define Related Issue(s) ##
Consider the impact to the other METplus components.
Expand All @@ -67,14 +68,15 @@ Branch name: `feature_<Issue Number>_<Description>`
- [ ] Add/update log messages for easier debugging.
- [ ] Add/update unit tests.
- [ ] Add/update documentation.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/overview.html#metplus-components-python-requirements) table.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/appendixA.html#metplus-components-python-packages) table.
- [ ] For any new datasets, an entry to the [METplus Verification Datasets Guide](https://metplus.readthedocs.io/en/latest/Verification_Datasets/index.html).
- [ ] Push local changes to GitHub.
- [ ] Submit a pull request to merge into **develop**.
Pull request: `feature <Issue Number> <Description>`
- [ ] Define the pull request metadata, as permissions allow.
Select: **Reviewer(s)** and **Development** issues
Select: **Repository** level development cycle **Project** for the next official release
Select: **Reviewer(s)** and **Development** issue
Select: **Milestone** as the next official version
Select: **METplus-Wrappers-X.Y.Z Development** project for development toward the next official release
- [ ] Iterate until the reviewer(s) accept your changes. Merge branch into **develop**.
- [ ] Create a second pull request to merge **develop** into **develop-ref**, following the same steps for the first pull request.
- [ ] Delete your fork or branch.
Expand Down
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/sub-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ This is a sub-issue of #*List the parent issue number here*.
- [ ] Select **scientist(s)** or **no scientist** required

### Labels ###
- [ ] Review default **alert** labels
- [ ] Select **component(s)**
- [ ] Select **priority**
- [ ] Select **requestor(s)**

### Projects and Milestone ###
- [ ] Select **Repository** and/or **Organization** level **Project(s)** or add **alert: NEED CYCLE ASSIGNMENT** label
- [ ] Select **Milestone** as the next official version or **Future Versions**
### Milestone and Projects ###
- [ ] Select **Milestone** as a **METplus-Wrappers-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas**
- [ ] For a **METplus-Wrappers-X.Y.Z** version, select the **METplus-Wrappers-X.Y.Z Development** project

14 changes: 8 additions & 6 deletions .github/ISSUE_TEMPLATE/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ Consider breaking the task down into sub-issues.
- [ ] Select **scientist(s)** or **no scientist** required

### Labels ###
- [ ] Review default **alert** labels
- [ ] Select **component(s)**
- [ ] Select **priority**
- [ ] Select **requestor(s)**

### Projects and Milestone ###
- [ ] Select **Repository** and/or **Organization** level **Project(s)** or add **alert: NEED CYCLE ASSIGNMENT** label
- [ ] Select **Milestone** as the next official version or **Future Versions**
### Milestone and Projects ###
- [ ] Select **Milestone** as a **METplus-Wrappers-X.Y.Z** version, **Consider for Next Release**, or **Backlog of Development Ideas**
- [ ] For a **METplus-Wrappers-X.Y.Z** version, select the **METplus-Wrappers-X.Y.Z Development** project

## Define Related Issue(s) ##
Consider the impact to the other METplus components.
Expand All @@ -54,14 +55,15 @@ Branch name: `feature_<Issue Number>_<Description>`
- [ ] Add/update log messages for easier debugging.
- [ ] Add/update unit tests.
- [ ] Add/update documentation.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/overview.html#metplus-components-python-requirements) table.
- [ ] Add any new Python packages to the [METplus Components Python Requirements](https://metplus.readthedocs.io/en/develop/Users_Guide/appendixA.html#metplus-components-python-packages) table.
- [ ] For any new datasets, an entry to the [METplus Verification Datasets Guide](https://metplus.readthedocs.io/en/latest/Verification_Datasets/index.html).
- [ ] Push local changes to GitHub.
- [ ] Submit a pull request to merge into **develop**.
Pull request: `feature <Issue Number> <Description>`
- [ ] Define the pull request metadata, as permissions allow.
Select: **Reviewer(s)** and **Development** issues
Select: **Repository** level development cycle **Project** for the next official release
Select: **Reviewer(s)** and **Development** issue
Select: **Milestone** as the next official version
Select: **METplus-Wrappers-X.Y.Z Development** project for development toward the next official release
- [ ] Iterate until the reviewer(s) accept and merge your changes.
- [ ] Delete your fork or branch.
- [ ] Close this issue.
62 changes: 62 additions & 0 deletions .github/ISSUE_TEMPLATE/update_truth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Update Truth
about: Review use case differences that are caused by changes in an external repository and update truth dataset if necessary.
title: 'Update Truth: '
labels: 'alert: NEED ACCOUNT KEY, alert: NEED MORE DEFINITION, alert: NEED CYCLE ASSIGNMENT, type: update truth, priority: blocker, component: CI/CD, requestor: METplus Team'
assignees: ''

---

## Describe Expected Changes ##

*Write a short summary of the differences that will likely be found in the GitHub Actions testing workflow that was triggered by the pull request that warranted this issue*

- [ ] Link to relevant issue(s):
- [ ] Link to relevant pull request(s):

## Define the Metadata ##

### Title ###
- [ ] Define the **Title** of this issue as **Update Truth: For dtcenter/{REPO}#{PR_NUMBER}** to indicate the repository and pull request that warranted this issue.

### Assignee ###

*Assign this issue to the author of the pull request that warranted this issue. Optionally assign anyone else who should review the differences in the output.*

- [ ] Select **engineer(s)** or **no engineer** required
- [ ] Select **scientist(s)** or **no scientist** required

### Milestone and Projects ###
- [ ] Select **Milestone** as the next official version if updating truth data for the `develop` branch **OR** select next **METplus-Wrappers-X.Y.Z bugfix** version if updating truth data for a `main_vX.Y` branch.
- [ ] If updating truth data for the `develop` branch, select the **METplus-Wrappers-X.Y.Z Development** project **OR** if updating truth for a `main_vX.Y` branch, select the **Coordinated METplus-X.Y Support** project


## Update Truth Checklist ###
- [ ] Review the GitHub Actions workflow that was triggered by the PR merge
- If no differences were found, note this in a comment.
- If all of the differences are expected, note this in a comment.
Include any details of how the review was performed.
- If unexpected differences are found, the following instructions can
help uncover potential explanations. If none of these apply and the
source of the differences cannot be determined, contact the
METplus wrappers lead engineer (@georgemccabe) for assistance.
- Search for other open issues that have the label `type: update truth`
applied by clicking on the label on this issue. Coordinate with the
author of these issues to ensure all diffs are properly reviewed.
- Check if any additional GitHub Actions testing workflows have been
triggered since the workflow that corresponds to this issue was run.
Review the latest run to ensure that there are no diffs that are
unrelated to this issue.
- If the incorrect differences are caused by the changes from the
issue that warranted this issue, consider reverting the PR and
re-opening the issue.
- Iterate until one of the above conditions apply.
- [ ] Approve the update of the truth data
- Contact the METplus wrappers lead engineer (@georgemccabe) or
backup lead (@jprestop) to let them know that the truth data can
be updated.
- [ ] Update the truth data.
This should be handled by a METplus wrappers engineer.
See the [instructions to update the truth data](https://metplus.readthedocs.io/en/develop/Contributors_Guide/continuous_integration.html#update-truth-data-update-truth-yml)
for more info.
- [ ] Close this issue.
4 changes: 1 addition & 3 deletions .github/actions/run_tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ FROM alpine:latest
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

RUN apk add --update --no-cache docker python3 py3-pip bash

RUN pip3 install python-dateutil requests
RUN apk add --update --no-cache docker python3 py3-pip bash py3-dateutil py3-requests

ENTRYPOINT ["/entrypoint.sh"]
9 changes: 9 additions & 0 deletions .github/jobs/build_conda_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DOCKER_ENV_DIR=${GITHUB_WORKSPACE}/internal/scripts/docker_env
cmd="docker build \
-t dtcenter/metplus-envs:${ENV_NAME}.${METPLUS_ENV_VERSION} \
--build-arg METPLUS_ENV_VERSION \
--build-arg BASE_ENV \
--build-arg ENV_NAME \
-f ${DOCKER_ENV_DIR}/${DOCKERFILE} ${DOCKER_ENV_DIR}"
echo $cmd
$cmd
63 changes: 63 additions & 0 deletions .github/jobs/configure_sonarqube.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Constants
SONAR_PROPERTIES_DIR=internal/scripts/sonarqube
SONAR_PROPERTIES=sonar-project.properties

# Check that this is being run from the top-level METplus directory
if [ ! -e $SONAR_PROPERTIES_DIR/$SONAR_PROPERTIES ]; then
echo "ERROR: ${0} -> must be run from the top-level METplus directory"
exit 1
fi

# Check required environment variables
if [ -z ${SOURCE_BRANCH+x} ]; then
echo "ERROR: ${0} -> \$SOURCE_BRANCH not defined!"
exit 1
fi
if [ -z ${WD_REFERENCE_BRANCH+x} ]; then
echo "ERROR: ${0} -> \$WD_REFERENCE_BRANCH not defined!"
exit 1
fi
if [ -z ${SONAR_HOST_URL+x} ]; then
echo "ERROR: ${0} -> \$SONAR_HOST_URL not defined!"
exit 1
fi
if [ -z ${SONAR_TOKEN+x} ]; then
echo "ERROR: ${0} -> \$SONAR_TOKEN not defined!"
exit 1
fi

# Define the version string
SONAR_PROJECT_VERSION=$(cat metplus/VERSION)

#
# Define the $SONAR_REFERENCE_BRANCH as the
# - Target of any requests
# - Manual setting for workflow dispatch
# - Source branch for any pushes (e.g. develop)
#
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
export SONAR_REFERENCE_BRANCH=$GITHUB_BASE_REF
elif [ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]; then
export SONAR_REFERENCE_BRANCH=$WD_REFERENCE_BRANCH
else
export SONAR_REFERENCE_BRANCH=$SOURCE_BRANCH
fi

# Configure the sonar-project.properties
[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES
sed -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \
-e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \
-e "s|SONAR_TOKEN|$SONAR_TOKEN|" \
-e "s|SONAR_BRANCH_NAME|$SOURCE_BRANCH|" \
$SONAR_PROPERTIES_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES

# Define new code when the source and reference branches differ
if [ "$SOURCE_BRANCH" != "$SONAR_REFERENCE_BRANCH" ]; then
echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES
fi

echo "Contents of the $SONAR_PROPERTIES file:"
cat $SONAR_PROPERTIES

Loading

0 comments on commit 5efcdc2

Please sign in to comment.