Skip to content
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
58 changes: 58 additions & 0 deletions .github/actions/badge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'Create badge'
description: Create and upload a custom badge
inputs:
label:
type: string
description: Badge name
required: true
status:
type: string
description: Status. Pass/Fail, or numeric, Pass will set color to green, Fail to red, anything else is blue.
required: true
file:
type: string
description: Name of file to create, can include folders
required: true
run_id:
type: number
description: The value of github.run_id, or another appropriate tracker for downstream use.
required: true
outputs: {}
runs:
using: "composite"
steps:
- name: Badge directory
shell: bash
run: mkdir -p "badges/$(dirname '${{inputs.file}}')" || true
- name: Prepare variables
id: vars
shell: bash
env:
UNSAFE: ${{ inputs.file }}
run: |
# Act, which we use for testing, doesn't yet support case in expression
# However we may keep this to handle some more complex cases anyways.
case "${{ inputs.status}}" in
"Pass")
echo "color=green" >> $GITHUB_OUTPUT
;;
"Fail")
echo "color=red" >> $GITHUB_OUTPUT
;;
*)
echo "color=blue" >> $GITHUB_OUTPUT
esac
echo "safe_file=${UNSAFE//\//_}" >> $GITHUB_OUTPUT
- name: Build Badge
uses: emibcn/badge-action@v2.0.2
with:
label: ${{inputs.label}}
status: ${{inputs.status}}
color: ${{ steps.vars.outputs.color }}
path: badges/${{inputs.file}}
- name: Upload badge
uses: actions/upload-artifact@v4
with:
name: badges_${{ inputs.run_id }}_${{ steps.vars.outputs.safe_file }}
path: badges/**/*.svg
overwrite: true
1 change: 1 addition & 0 deletions .github/actions/database-migration-image/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: 'Database Migration Container'
description: Setup database migration container.
inputs:
base-image:
type: string
Expand Down
53 changes: 47 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ jobs:
fail-fast: false
matrix:
jdk: [11]
# place holder for now and leaving commented but in place. General scheme target tests again the current release, the next release, the previous release, and latest development.
# at this time every possible instance of concern is on 25.07.01, once 26.02.17 is finalized it becomes release and 25.07.01 becomes previous.
# next-release will be comment out until such time as a RC gets made
schema:
- env: latest
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:latest-dev"
- env: release
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:25.07.01"
- env: next-release
image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:26.02.17-RC01"
# - env: previous
# image: "ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/database-ready-ora-23.5:25.07.01"
name: build and test (jdk ${{matrix.jdk}}, schema ${{matrix.schema.env}})
runs-on: ubuntu-latest
outputs:
Expand All @@ -44,13 +49,21 @@ jobs:
run: ./gradlew clean build --info --init-script init.gradle
- name: integration tests
run: ./gradlew integrationtest --info --init-script init.gradle -PCDA.oracle.database.image=${{matrix.schema.image}}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
- name: Create matrix job badge
if: success() || failure() # always run even if the previous step fails
uses: ./.github/actions/badge
with:
annotate_only: true
include_passed: true
report_paths: '**/TEST-*.xml'
label: 'Build'
status: ${{ job.status == 'success' && 'Pass' || 'Fail' }}
file: ${{ matrix.jdk }}/${{ matrix.schema.env }}.svg
run_id: ${{ github.run_id }}
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v5
# if: success() || failure() # always run even if the previous step fails
# with:
# annotate_only: true
# include_passed: true
# report_paths: '**/TEST-*.xml'
open-api-static-analysis:
name: OpenApi Static Analysis Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -88,11 +101,39 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v5.0.0
# No uploads, we're just verifying that nothing broke the docker image.
- name: Build Migration image
uses: ./.github/actions/database-migration-image
with:
base-image: ghcr.io/hydrologicengineeringcenter/cwms-database/cwms/schema_installer
# TODO get current target image from build information
tag: latest-dev

# No uploads, we're just verifying that nothing broke the docker image.


badges:
needs: build
runs-on: ubuntu-latest
# we are reporing build state so always run, but only on builds on the main branch
if: always() && (github.ref_name == 'develop')
steps:
- name: Badge Branch
uses: actions/checkout@v5.0.0
with:
ref: badges
fetch-depth: 1
- name: Download badges
uses: actions/download-artifact@v4
with:
pattern: badges_${{ github.run_id }}_*
path: ./build # directory to download artifacts into
merge-multiple: true # downloaded artifacts will be in the same directory specified by path
- name: Apply Badge
run: |
find . -type f
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add build/**/*.svg
git status
git commit --allow-empty -m "Update Badge for build of ${{ github.sha }}"
git push origin badges -f
33 changes: 22 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,22 @@ jobs:
java-version: '11'
cache: 'gradle'
- name: Set version
if: inputs.nightly == true
run: echo "VERSION=${{inputs.branch}}-nightly" >> $GITHUB_ENV
- name: Set version
if: inputs.nightly == false
run: echo "VERSION=${{inputs.branch}}" >> $GITHUB_ENV
id: version
env:
NIGHTLY: ${{inputs.nightly}}
run:
if [[ "${NIGHTLY}" == true ]]; then
echo "version=${{inputs.branch}}-nightly" >> $GITHUB_OUTPUT
else
echo "version=${{inputs.branch}}" >> $GITHUB_OUTPUT
fi
- name: Sanitize repo for container image names
id: repo
run: |
REPO=`echo "${{github.repository}}" | tr '[:upper:]' '[:lower:]'`
echo "REPO=$REPO" >> $GITHUB_ENV
echo "name=$REPO" >> $GITHUB_OUTPUT
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is $REPO coming from I see it removed in other places

- name: show version
run: echo ${VERSION}
run: echo ${{ steps.version.outputs.version }}
- name: build war
run: ./gradlew build --info --init-script init.gradle -PversionOverride=$VERSION
- name: Create GitHub Release
Expand All @@ -86,8 +91,8 @@ jobs:
if: github.event_name != 'pull_request' && (github.event.ref == 'refs/heads/develop' || startsWith(github.event.ref, 'refs/tags'))
uses: softprops/action-gh-release@v2.6.1
with:
files: cwms-data-api/build/libs/cwms-data-api-${{env.VERSION}}.war
tag_name: ${{env.VERSION}}
files: cwms-data-api/build/libs/cwms-data-api-${{steps.version.outputs.version}}.war
tag_name: ${{steps.version.outputs.version}}
generate_release_notes: true
token: ${{ secrets.token != null && secrets.token || secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
Expand All @@ -101,11 +106,11 @@ jobs:
context: git
images: |
${{secrets.registry != null && secrets.registry ||secrets.HEC_PUB_REGISTRY}}/cwms/data-api
ghcr.io/${{env.REPO}}
ghcr.io/${{steps.repo.outputs.name}}
tags: |
type=sha
type=ref,event=tag
type=raw,value=${{env.VERSION}}
type=raw,value=${{steps.version.outputs.version}}
type=schedule,pattern=${{inputs.branch}}-{{date 'YYYY.MM.DD'}}
type=schedule,pattern=${{inputs.branch}}-{{date 'YYYY.MM.DD-hhmmss'}}
- name: Log in to the Container registry
Expand Down Expand Up @@ -133,6 +138,9 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
- name: Set Output Image
id: set_image
env:
REPO: ${{ steps.repo.outputs.name }}
VERSION: ${{ steps.version.outputs.version }}
run: |
echo "api_image=ghcr.io/${REPO}:$VERSION" >> $GITHUB_OUTPUT
- name: Setup Database Migration Image
Expand All @@ -143,6 +151,9 @@ jobs:
tag: latest-dev
- name: Publish migration container
id: migration-publish
env:
REPO: ${{ steps.repo.outputs.name }}
VERSION: ${{ steps.version.outputs.version }}
run: |
IMAGE=ghcr.io/${REPO}-schema-migration:$VERSION
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are some version references still? This might be empty now

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{REPO} as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are now set in the env: block you see starting on line 151.

docker tag ${{steps.migration.outputs.image}} $IMAGE
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pki/certs
compose.env
.vscode
**/node_modules/
cwms-data-api/features.properties
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
</p>

<p align="center">
<a href="https://github.com/usace/cwms-data-api/actions/workflows/build.yml">
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/usace/cwms-data-api/build.yml?branch=develop&style=for-the-badge&label=Build&logo=githubactions">
</a>
<a href="https://github.com/usace/cwms-data-api/actions/workflows/codeql.yml">
<img alt="CodeQL Status" src="https://img.shields.io/github/actions/workflow/status/usace/cwms-data-api/codeql.yml?branch=develop&style=for-the-badge&label=CodeQL&logo=githubactions">
</a>
Expand All @@ -23,6 +20,36 @@
</a>
</p>

<div align="center">
<h2>Detailed Build Status</h2>
<table>
<thead>
<tr>
<th>CWMS Database Schema target</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>Latest</td>
<td><img alt="Latest Status, Svg" src="https://raw.githubusercontent.com/USACE/cwms-data-api/refs/heads/badges/build/11/latest.svg">
</tr>
<tr>
<td>Current Release</td>
<td><img alt="Current Status, Svg" src="https://raw.githubusercontent.com/USACE/cwms-data-api/refs/heads/badges/build/11/release.svg">
</tr>
<tr>
<td>Next Release</td>
<td><img alt="Next Status, Svg" src="https://raw.githubusercontent.com/USACE/cwms-data-api/refs/heads/badges/build/11/next-release.svg">
</tr>
<tr>
<td>Previous Release - NOTE: Not applicable yet</td>
<td><img alt="Previous Status, Svg" src="https://raw.githubusercontent.com/USACE/cwms-data-api/refs/heads/badges/build/11/previous.svg">
</tr>
</tbody>
</table>
</div>

<p align="center">
<strong>
<a href="CONTRIBUTING.md">Contributing</a>
Expand Down
Loading