Skip to content

Commit

Permalink
Use reusable workflow for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabasoad committed Jul 2, 2024
1 parent 9cb7adf commit 2e6f78f
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 235 deletions.
78 changes: 0 additions & 78 deletions .github/labels.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
name: Pre-commit
uses: fabasoad/reusable-workflows/.github/workflows/wf-pre-commit.yml@main
with:
skip-hooks: "build, snyk-test, test"
skip-hooks: "build, test"
32 changes: 7 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
---
name: Release

on:
on: # yamllint disable-line rule:truthy
push:
tags:
- 'v*.*.*'
- "v*.*.*"

jobs:
create-release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changelog
id: changelog
uses: simbo/changes-since-last-release-action@v1
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
body: |
# Changelog
${{ steps.changelog.outputs.log }}
draft: false
prerelease: false
github:
name: GitHub
uses: fabasoad/reusable-workflows/.github/workflows/wf-github-release.yml@main
with:
bump-tags: false
73 changes: 12 additions & 61 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,19 @@
name: Security

on: # yamllint disable-line rule:truthy
pull_request: {}
push:
branches:
- 'main'
pull_request:

defaults:
run:
shell: sh
- main

jobs:
code-scanning:
name: Code scanning
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Get versions
id: versions
run: |
java_version=$(grep -Eo 'java [a-z0-9.-]+' .tool-versions | cut -d'-' -f2)
echo "java=${java_version}" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ steps.versions.outputs.java }}
distribution: temurin
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: "8.8"
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "java"
- name: Build
env:
SKIP_FINALIZE: true
run: ./gradlew build
- name: Perform CodeQL Analysis
id: codeql-analysis
uses: github/codeql-action/analyze@v3
- name: Upload to GHAS
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
category: "code-scanning"
sarif_file: "${{ steps.codeql-analysis.outputs.sarif-output }}"
directory-scanning:
name: Directory scanning
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Scan current project
id: scan-directory
uses: anchore/scan-action@v3
with:
by-cve: "true"
path: "."
- name: Upload to GHAS
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
category: "directory-scanning"
sarif_file: "${{ steps.scan-directory.outputs.sarif }}"
sast:
name: SAST
permissions:
contents: read
security-events: write
uses: fabasoad/reusable-workflows/.github/workflows/wf-security-sast.yml@feat/java-ut
with:
code-scanning-languages: "java"
code-scanning-build-mode: "manual"
code-scanning-build-command: "./gradlew build"
19 changes: 5 additions & 14 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
---
name: Sync labels
name: Labels

on: # yamllint disable-line rule:truthy
push:
branches:
- main
paths:
- .github/labels.yml
workflow_dispatch:
workflow_dispatch: {}

jobs:
sync-labels:
name: Sync labels
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Run Label Syncer
uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
maintenance:
name: Maintenance
uses: fabasoad/reusable-workflows/.github/workflows/wf-sync-labels.yml@main
44 changes: 14 additions & 30 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
---
name: Unit Tests

on:
on: # yamllint disable-line rule:truthy
pull_request:
paths:
- gradle/**
- tasks/Makefile.java.mk
- Makefile
- src/**
- build.gradle
- ./gradlew
- ./gradlew.bat
push:
branches:
- 'main'
pull_request:
- main

jobs:
unit-tests:
name: Test
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Get versions
id: versions
run: |
java_version=$(grep -Eo 'java [a-z0-9.-]+' .tool-versions | cut -d'-' -f2)
echo "java=$java_version" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ steps.versions.outputs.java }}
distribution: temurin
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: "8.8"
- name: Build
env:
SKIP_FINALIZE: true
run: ./gradlew build
- name: Unit tests
run: ./gradlew test
gradle:
name: Gradle
uses: fabasoad/reusable-workflows/.github/workflows/wf-java-unit-tests.yml@feat/java-ut
31 changes: 6 additions & 25 deletions .github/workflows/update-license.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
---
name: Update license
name: License

on:
on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 5 1 1 *'
- cron: "0 5 1 1 *"

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update LICENSE file
uses: FantasticFiasco/action-update-license-year@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
assignees: ${{ github.repository_owner }}
labels: enhancement
prTitle: Update license copyright year to {{currentYear}}
prBody: |
## Changelog
- Update license copyright year to {{currentYear}}
---
Powered by [FantasticFiasco/action-update-license-year](https://github.com/FantasticFiasco/action-update-license-year)
maintenance:
name: Maintenance
uses: fabasoad/reusable-workflows/.github/workflows/wf-update-license.yml@main
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
- id: detect-secrets
stages: ["commit", "push"]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.3
rev: v8.18.4
hooks:
- id: gitleaks
stages: ["commit", "push"]
Expand All @@ -35,6 +35,14 @@ repos:
hooks:
- id: snyk-test
stages: ["push"]
- repo: https://github.com/fabasoad/pre-commit-grype
rev: v0.3.1
hooks:
- id: grype-dir
args:
- --grype-args=--by-cve --fail-on=low
- --hook-args=--log-level debug
stages: ["push"]
# Java
- repo: https://github.com/dustinsand/pre-commit-jvm
rev: v0.11.0
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gradle 8.8
java openjdk-22
coursier 2.1.9

0 comments on commit 2e6f78f

Please sign in to comment.