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

Feature/DCMAW-7374: initial repo setup #1

Merged
merged 9 commits into from
Dec 15, 2023
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
8 changes: 8 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

echo "Checking commit message conforms to conventional commit template"
commit_message="$1"
# exit with a non zero exit code incase of an invalid commit message

# use git-conventional-commits, see https://github.com/qoomon/git-conventional-commits
git-conventional-commits commit-msg-hook "$commit_message"
22 changes: 22 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Update versions
git fetch --all --tags
RAW_TAG=$(git describe --match "v*" --abbrev=0 --tags $(git rev-list --tags --max-count=1))
TAG="${RAW_TAG:1}"
cat app/gradle.properties \
| sed "s/versionName=.*/versionName=$TAG/" \
| sed "s/versionCode=.*/versionCode=`date +%s`/" \
> app/gradle.properties.new \
&& mv app/gradle.properties.new app/gradle.properties \
&& git add app/gradle.properties

# Run checks
# Linting is done on a per-environment basis, due to the differing values that exist.
./gradlew \
detekt \
ktlintCheck \
lintDebug \
testDebugUnitTest \
vale \
--daemon
22 changes: 22 additions & 0 deletions .github/conventional_commit_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<type>(<optional scope>): <description>

# [optional body]

# [optional footer(s)]
# Reference JIRA tickets here:
# Resolves: DCMAW-000, GOVAPP-000

# Uncomment below line to include details of any breaking changes
# BREAKING CHANGES:

# Types
# feat - Commits, that adds a new feature, add ! before the : for breaking change
# fix - Commits, that fixes a bug
# refactor - Commits, that rewrite/restructure your code, however does not change any behaviour
# perf - Commits are special refactor commits, that improve performance
# style - Commits, that do not affect the meaning (white-space, formatting, missing semi-colons, etc)
# test - Commits, that add missing tests or correcting existing tests
# docs - Commits, that affect documentation only
# build - Commits, that affect build components like build tool, ci pipeline, dependencies, project version, ...
# ops - Commits, that affect operational components like infrastructure, deployment, backup, recovery, ...
# chore - Miscellaneous commits e.g. modifying .gitignore
75 changes: 75 additions & 0 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: On Pull Request (develop/release/main)

on:
pull_request:
branches:
- develop
- main
- release/*
types:
- opened
- reopened
- synchronize
- ready_for_review
merge_group:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
onPullRequestJob:
name: Verify code base when pull request is published/updated
runs-on: macos-latest

steps:
- name: Run checkout github action
uses: actions/checkout@v4
with:
lfs: 'true'
fetch-depth: 0

- name: Detect Arch
id: detect-arch
uses: ./config/actions/detect-arch

- name: Setup GitHub Runner workflow
uses: ./config/actions/setup-runner

- name: Get latest tag
id: latest-tag
uses: ./config/actions/get-latest-tag
with:
pattern: 'v*'

- name: Generate version code
id: version-code
uses: ./config/actions/generate-version-code

- name: Generate version name
id: version-name
uses: ./config/actions/version-name
with:
version-code: ${{ steps.version-code.outputs.version-code }}
version-name: ${{ steps.latest-tag.outputs.current-tag }}

- name: Run gradle instrumentation tests
uses: ./config/actions/gradle-connected-test
with:
architecture: 'arm64-v8a'
device-profile: 'Nexus 6'
if: steps.detect-arch.outputs.arch-in-use == 'arm64'

- name: Run gradle instrumentation tests
uses: ./config/actions/gradle-connected-test
alex-bradbury marked this conversation as resolved.
Show resolved Hide resolved
if: steps.detect-arch.outputs.arch-in-use != 'arm64'

- name: Run sonar analysis
uses: ./config/actions/sonar-analysis
with:
project-version: ${{ steps.version-name.outputs.version-name }}
sonar-token: ${{ secrets.SONAR_TOKEN }}

- name: Bundle reports folder
uses: ./config/actions/bundle-reports
64 changes: 64 additions & 0 deletions .github/workflows/on_push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: On Branch Push (main)

on:
push:
branches:
- "main"
workflow_dispatch:

jobs:
onPushDevelopJob:
name: Verify code base when pushed
runs-on: macos-latest
# runs-on: ubuntu-20.04-16core # Larger github runner, with KVM acceleration
permissions:
# id-token: write
contents: write
packages: write
steps:
- name: Run checkout github action
uses: actions/checkout@v4
with:
lfs: 'true'
fetch-depth: 0

- name: Detect Arch
id: detect-arch
uses: ./config/actions/detect-arch

- name: Setup GitHub Runner workflow
uses: ./config/actions/setup-runner

- name: Get latest tag
id: latest-tag
uses: ./config/actions/get-latest-tag
with:
pattern: 'v*'

- name: Generate version name
id: version-name
uses: ./config/actions/version-name
with:
version-code: ${{ steps.version-code.outputs.version-code }}
version-name: ${{ steps.latest-tag.outputs.current-tag }}

- name: Bundle release
id: bundle-release
uses: ./config/actions/gradle-assemble-and-bundle
with:
version-name: ${{ steps.version-name.outputs.version-name }}

- name: Release package
uses: ./config/actions/maven-publish
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
package-version: ${{ steps.version-name.outputs.version-name }}
username: ${{ github.actor }}

- name: Git tag bundles
uses: ./config/actions/git-tag-bundles
with:
version-name: ${{ steps.version-name.outputs.version-name }}

- name: Clean workspace
uses: ./config/actions/clean-workspace
116 changes: 116 additions & 0 deletions .github/workflows/on_push-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: On Branch Push (release)

on:
push:
branches:
- "release/**"
workflow_dispatch:

jobs:
prepareForRelease:
name: Verify code base when pushed
runs-on: macos-latest
# runs-on: ubuntu-20.04-16core # Larger github runner, with KVM acceleration
permissions:
# id-token: write
contents: write
outputs:
version: ${{ steps.version-number.outputs.version }}
steps:
- name: Run checkout github action
uses: actions/checkout@v4
with:
lfs: 'true'
fetch-depth: 0

- name: Detect Arch
id: detect-arch
uses: ./config/actions/detect-arch

- name: Setup GitHub Runner workflow
uses: ./config/actions/setup-runner

- name: Retrieve secrets
uses: ./config/actions/retrieve-secrets
with:
actions-role-arn: ${{ secrets.GITHUBRUNNER_EC2_ACTIONS_ROLE_ARN }}

- name: Get latest tag
id: latest-tag
uses: ./config/actions/get-latest-tag
with:
pattern: 'v*'

- name: Get next version from branch
id: next-version
uses: ./config/actions/get-next-version-from-branch

- name: Ensure version is correct
id: version-number
uses: ./config/actions/ensure-version-is-correct
with:
current-version: ${{ steps.latest-tag.outputs.current-tag }}
next-version: ${{ steps.next-version.outputs.next-version }}

- name: Display version jump
run: |
echo "Moving from $CURRENT_VERSION to $NEXT_VERSION"
shell: bash
env:
CURRENT_VERSION: ${{ steps.latest-tag.outputs.current-tag }}
NEXT_VERSION: ${{ steps.version-number.outputs.version }}

buildAndPublishRelease:
name: Verify code base when pushed
needs: prepareForRelease
runs-on: android-runner-prod
environment: release

steps:
- name: Run checkout github action
uses: actions/checkout@v4
with:
lfs: 'true'
fetch-depth: 0

- name: Detect Arch
id: detect-arch
uses: ./config/actions/detect-arch

- name: Setup GitHub Runner workflow
uses: ./config/actions/setup-runner

- name: Retrieve secrets
uses: ./config/actions/retrieve-secrets
with:
actions-role-arn: ${{ secrets.GITHUBRUNNER_EC2_ACTIONS_ROLE_ARN }}

- name: Generate version code
id: version-code
uses: ./config/actions/generate-version-code

- name: Bundle release
id: bundle-release
uses: ./config/actions/gradle-assemble-and-bundle
with:
flavors: 'staging,production'
version-code: ${{ steps.version-code.outputs.version-code }}
version-name: ${{ needs.prepareForRelease.outputs.version }}

- name: Upload to play store
uses: ./config/actions/upload-to-play-store
with:
aab-paths: ${{ steps.bundle-release.outputs.aab-paths }}

- name: Git tag bundles
uses: ./config/actions/git-tag-bundles
with:
aab-paths: ${{ steps.bundle-release.outputs.aab-paths }}
version-code: ${{ steps.version-code.outputs.version-code }}
version-name: ${{ steps.version-name.outputs.version-name }}

- name: Upload documentation
uses: ./config/actions/upload-dokka

- name: Clean workspace
uses: ./config/actions/clean-workspace
56 changes: 56 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: On Branch Push (non-develop/release/main)

on:
push:
branches:
- "**"
- "!develop"
- "!release/**"
- "!main"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
onPushJob:
name: Verify code base when pushed
runs-on: macos-latest
# runs-on: ubuntu-20.04-16core # Larger github runner, with KVM acceleration
steps:
- name: Run checkout github action
uses: actions/checkout@v4
with:
lfs: 'true'
fetch-depth: 0

- name: Detect Arch
id: detect-arch
uses: ./config/actions/detect-arch

- name: Setup GitHub Runner workflow
uses: ./config/actions/setup-runner

- name: Get latest tag
id: latest-tag
uses: ./config/actions/get-latest-tag
with:
pattern: 'v*'

- name: Generate version code
id: version-code
uses: ./config/actions/generate-version-code

- name: Generate version name
id: version-name
uses: ./config/actions/version-name
with:
version-code: ${{ steps.version-code.outputs.version-code }}
version-name: ${{ steps.latest-tag.outputs.current-tag }}

- name: Run gradle unit tests
uses: ./config/actions/gradle-check

- name: Bundle reports folder
uses: ./config/actions/bundle-reports
Loading