Skip to content

Commit

Permalink
Issue #1: Add Maven Java Example
Browse files Browse the repository at this point in the history
  • Loading branch information
ALRubinger committed Sep 27, 2024
1 parent 84c248f commit f1ea8e0
Show file tree
Hide file tree
Showing 60 changed files with 1,606 additions and 6 deletions.
8 changes: 5 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 🐛 Bug Report
about: Thank you for taking the time, please report a reproducible bug
title: "[Bug] <Bug Title Here>"
labels: bug
assignees: add codeowner's @name here
assignees: nitro-neal, jiyoontbd, mistermoe

---

Expand All @@ -12,6 +12,7 @@ assignees: add codeowner's @name here

**To Reproduce:**
*Steps to reproduce the behavior:*

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,8 +25,9 @@ assignees: add codeowner's @name here
*If applicable, add screenshots, output log and/or other documentation to help explain your problem.*

**Environment (please complete the following information):**
- OS: [ex: iOS]
- Version

- OS: [ex: iOS]
- Version

**Additional context**
Add any other context that you feel is relevant about the problem here.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
contact_links:
- name: ❓ Questions and Help 🤔
url: https://discord.gg/tbd (/add your discord channel if applicable)
about: This issue tracker is not for support questions. Please refer to the community for more help.
- name: ❓ Questions and Help 🤔
url: https://discord.gg/tbd (/add your discord channel if applicable)
about: This issue tracker is not for support questions. Please refer to the community for more help.
23 changes: 23 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Overview
_Include a summary of the change and link to the issue it addresses._

# Description
_Include context, motivation, brief description, and an impact of the change(s). List follow-up tasks here._

# How Has This Been Tested?
_Describe the tests that you ran to verify your changes. Provide instructions for verification._

- [ ] Test A (e.g. Test A - New test that does ... run in ...)
- [ ] Test B

# Checklist

Before submitting this PR, please make sure:

- [ ] I have read the CONTRIBUTING document.
- [ ] My code is consistent with the rest of the project
- [ ] I have tagged the relevant reviewers and/or interested parties
- [ ] I have updated the READMEs and other documentation of affected packages

## References
_Please list relevant documentation (e.g. tech specs, articles, follow up or related work) relevant to this change, and note if the documentation has been updated._
132 changes: 132 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Runs on every commit to main. This is the main CI job; it runs in MacOS and Ubuntu environments which:
# * Build
# * Run tests
#
# In the Ubuntu environment only, to avoid double uploads from MacOS, it also:
# * Uploads Test reports to BuildKite
# * Uploads Coverage reports to CodeCov
# * Publishes (deploys) to Block's SaaS Artifactory instance as version commit-$shortSHA-SNAPSHOT
#
# If triggered from workflow_dispatch, you may select a branch or tag to
# deploy as an internal "release" (or SNAPSHOT, depending upon the version in the POM)
# to Block's SaaS Artifactory instance by not specifying a version.
name: CI

on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish. For example "1.0.0-SNAPSHOT". If not supplied, will default to version specified in the POM. Must end in "-SNAPSHOT".'
required: false
default: "0.0.0-SNAPSHOT"
push:
branches:
- main
pull_request:
branches:
- main

jobs:
# On MacOS we only build, test, and verify
build-test-macos:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

# https://cashapp.github.io/hermit/usage/ci/
- name: Init Hermit
uses: cashapp/activate-hermit@v1
with:
cache: true

- name: Build, Test, and Verify
run: |
# Maven "test" lifecycle will build and test only on MacOS
mvn test
# On Ubuntu we build, test, verify, and deploy: Code Coverage, Test Vectors, and SNAPSHOT artifacts to TBD Artifactory
build-test-deploy-snapshot-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

# https://cashapp.github.io/hermit/usage/ci/
- name: Init Hermit
uses: cashapp/activate-hermit@v1
with:
cache: true

- name: Resolve Snapshot Version
id: resolve_version
run: |
# Version resolution: use provided
if [ -n "${{ github.event.inputs.version }}" ]; then
resolvedVersion=${{ github.event.inputs.version }}
# Otherwise, construct a version for deployment in form X.Y.Z-commit-$shortSHA-SNAPSHOT
else
longSHA=$(git rev-parse --verify HEAD)
shortSHA=$(echo "${longSHA:0:7}")
resolvedVersion="commit-$shortSHA-SNAPSHOT"
echo "Requesting deployment as version: $resolvedVersion"
fi
# Postcondition check; only allow this to proceed if we have a version ending in "-SNAPSHOT"
if [[ ! "$resolvedVersion" =~ -SNAPSHOT$ ]]; then
echo "Error: The version does not end with \"-SNAPSHOT\": $resolvedVersion"
exit 1
fi
echo "Resolved SNAPSHOT Version: $resolvedVersion"
echo "resolved_version=$resolvedVersion" >> $GITHUB_OUTPUT
- name: Build, Test, and Deploy to Block SaaS Artifactory
run: |
# Set newly resolved version in POM config
mvn \
versions:set \
--batch-mode \
-DnewVersion=${{ steps.resolve_version.outputs.resolved_version }}
# Only attempt to publish artifact if we have credentials
if [ -n "${{ secrets.ARTIFACTORY_PASSWORD }}" ]; then
# Maven deploy lifecycle will build, run tests, verify, sign, and deploy
mvn deploy --batch-mode --settings .maven_settings.xml -P sign-artifacts
else
# Otherwise, Maven verify lifecycle will build, run tests, and verify
mvn verify --batch-mode
fi
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }}
SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
flags: ${{ runner.os }}

- name: Upload JUnit tests report
uses: actions/upload-artifact@v3
with:
name: tests-report-junit
path: |
**/target/surefire-reports/*.xml
# Ensure both MacOS and Ubuntu build/test jobs succeeded
confirm-successful-build-and-tests:
# Wait on both jobs to succeed
needs: [build-test-macos, build-test-deploy-snapshot-ubuntu]
runs-on: ubuntu-latest

steps:
- name: Log Success
run: |
echo "Builds for MacOS and Ubuntu succeeded."
84 changes: 84 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '42 22 * * 1'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language: [ 'java-kotlin' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
Loading

0 comments on commit f1ea8e0

Please sign in to comment.