Skip to content

Commit

Permalink
Feat/simplify PR workflows (#39)
Browse files Browse the repository at this point in the history
* Renove release workflow

* Clip label validations in ci.yml

* Disable Cypress Nightly due to fails

* Remove release from merge-main.yml

* Remove sonarcloud from merge-main.yml
  • Loading branch information
DerekRoberts committed May 4, 2023
1 parent df79aea commit 7328f17
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 278 deletions.
14 changes: 0 additions & 14 deletions .github/release.yaml

This file was deleted.

30 changes: 3 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:

jobs:
tests-java:
name: Lint and Test
name: Java CI
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
strategy:
Expand All @@ -45,7 +45,7 @@ jobs:
sonar_project_token: ${{ secrets[matrix.token] }}

tests-javascript:
name: Lint and Tests
name: JavaScript CI
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
steps:
Expand All @@ -67,33 +67,9 @@ jobs:
-Dsonar.test.inclusions=src/**/__test__/**/*
sonar_project_token: ${{ secrets.SONAR_FRONTEND }}

validation-labels:
name: Label Validation
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3

- name: Pull request size and stability labels
uses: actions/labeler@v4
continue-on-error: true
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Conventional Label
uses: bcoe/conventional-release-labels@v1
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
ignored_types: '["chore","pr"]'
type_labels: '{"feat": "feature", "fix": "fix", "bug": "fix", "doc": "documentation", "ci": "ci", "chore": "chore", "breaking": "breaking", "BREAKING CHANGE": "breaking"}'

# https://github.com/marketplace/actions/aqua-security-trivy
trivy:
name: Trivy Security Scan
name: Security Scan
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
steps:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/cypress-nightly.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Cypress Nightly

on:
schedule:
# runs e2e tests every day at 4am
- cron: '0 4 * * *'
workflow_dispatch:
# schedule:
# # runs e2e tests every day at 4am
# - cron: '0 4 * * *'

jobs:
e2e-chrome:
Expand Down
135 changes: 0 additions & 135 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,145 +44,10 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

# SonarCloud runs in the main branch are needed to compare against PRs
sonarcloud:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/backend/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-test-
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- name: Unit Tests
run: mvn --no-transfer-progress test --file backend/pom.xml

- name: Integration Tests
run: mvn --no-transfer-progress verify -P integration-test --file backend/pom.xml

- name: Code Coverage
run: mvn --no-transfer-progress clean verify -P all-tests --file backend/pom.xml

- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
id: jacoco
with:
generate-branches-badge: true
jacoco-csv-file: backend/target/coverage-reports/merged-test-report/jacoco.csv

- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Commit the badge (if it changed)
run: |
if [[ `git status --porcelain` ]]; then
git config --global user.name 'CI Bot'
git config --global user.email 'cibot@users.noreply.github.com'
git add -A
git commit -m "ci: autogenerated JaCoCo coverage badge"
git push
fi
- name: Upload JaCoCo coverage report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: backend/target/coverage-reports/merged-test-report/

- name: SonarCloud Scan
run: mvn --no-transfer-progress clean verify package -P all-tests sonar:sonar -Dsonar.projectKey=bcgov_nr-spar-backend -Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml --file backend/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# Generate release notes and update new version
release:
name: Release Notes
runs-on: ubuntu-latest
outputs:
version: ${{ steps.changelog.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
fetch-depth: 0

- uses: actions/cache@v3
with:
path: |
~/.m2
key: ${{ runner.os }}-maven-test-${{ hashFiles('**/backend/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-test-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"

- name: Conventional Changelog Update
continue-on-error: true
uses: TriPSs/conventional-changelog-action@v3
id: changelog
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
output-file: "CHANGELOG.md"
skip-version-file: "true"
skip-commit: "true"
git-push: "false"
skip-on-empty: "false"

- name: Set new version
run: |
echo "::set-output name=version::${{ steps.changelog.outputs.version }}"
mvn versions:set -DnewVersion='${{ steps.changelog.outputs.version }}' -f backend/pom.xml -DskipTests -Dtests.skip=true -Dskip.unit.tests=true
- name: Update POM
run: mvn versions:commit --file backend/pom.xml

- name: Commit pom and changelog
uses: EndBug/add-and-commit@v9
with:
author_name: Ci Bot
author_email: cibot@users.noreply.github.com
message: "doc: updating pom to ${{ steps.changelog.outputs.version }} [ci skip]"
add: '["backend/pom.xml","CHANGELOG.md"]'

- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}

deploy-test:
name: TEST Deployment
needs:
- codeql
- sonarcloud
- release
environment: test
runs-on: ubuntu-22.04
strategy:
Expand Down
99 changes: 0 additions & 99 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit 7328f17

Please sign in to comment.