Skip to content

feat(7-kyu): kata/from-a-to-z (#437) #901

feat(7-kyu): kata/from-a-to-z (#437)

feat(7-kyu): kata/from-a-to-z (#437) #901

Workflow file for this run

name: Build CI
on:
push:
tags: [ '[0-9]+.[0-9]+.[0-9]+' ]
branches: [ main ]
pull_request:
branches: [ main ]
types: [ opened, reopened, synchronize ]
paths:
- .github/workflows/**
- gradle/**
- kata/**
- build.gradle.kts
- settings.gradle.kts
- gradle.properties
workflow_dispatch:
inputs:
ref_name:
description: Branch, tag or SHA to checkout
job_count:
description: Max concurrent jobs to execute
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
fork:
runs-on: ubuntu-22.04
timeout-minutes: 1
outputs:
job_count: ${{ steps.job.outputs.count }}
job_sid: ${{ steps.job.outputs.sid }}
steps:
- name: Assign job IDs
id: job
run: |
# set default as inputs resolve only at manual executions
JOB_COUNT=${{ github.event.inputs.job_count || 40 }}
echo "count=$JOB_COUNT" >> $GITHUB_OUTPUT
echo "sid=[`seq -s , 1 $JOB_COUNT`]" >> $GITHUB_OUTPUT
# ------------------------
test:
needs: fork
runs-on: ubuntu-22.04
timeout-minutes: 8
strategy:
matrix:
job_sid: ${{ fromJson(needs.fork.outputs.job_sid) }}
steps:
- name: Checkout repository (default ref)
if: ${{ github.event.inputs.ref_name == '' }}
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
- name: Checkout repository (custom ref)
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
if: ${{ github.event.inputs.ref_name != '' }}
with:
ref: ${{ github.event.inputs.ref_name }}
- name: Switch to Gradle Binary Distribution
run: sed -i 's/-all.zip/-bin.zip/' gradle/wrapper/gradle-wrapper.properties
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Test project
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a
with:
gradle-home-cache-cleanup: true
arguments: |
test jacocoTestReport -x processResources -x processTestResources
--parallel
--build-cache
--no-daemon
--scan
-DforkCount=${{ needs.fork.outputs.job_count }}
-DforkSid=${{ matrix.job_sid }}
- name: Pack fork artifacts
run: |
find . -path "*/main/*.class" -o -path "*/test/*.class" -o -path "*/jacocoTestReport.xml" > artifacts
tar czfT artifacts.tar.gz artifacts
- name: Upload fork artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: fork-${{ matrix.job_sid }}
retention-days: 1
path: artifacts.tar.gz
# ------------------------
scan:
needs: test
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
contents: write
env:
VERSION: 1.19.0
steps:
- name: Checkout repository (default ref)
if: ${{ github.event.inputs.ref_name == '' }}
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
fetch-depth: 0
- name: Checkout repository (custom ref)
if: ${{ github.event.inputs.ref_name != '' }}
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ github.event.inputs.ref_name }}
- name: Download fork artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
- name: Unpack fork artifacts
run: for f in fork-*/artifacts.tar.gz; do tar xf $f && rm $f; done
- name: Switch to Gradle Binary Distribution
run: sed -i 's/-all.zip/-bin.zip/' gradle/wrapper/gradle-wrapper.properties
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Analyze code quality (main)
if: startsWith(github.event_name, 'pull_request') == false
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a
with:
gradle-home-cache-cleanup: true
dependency-graph: generate-and-submit
arguments: |
sonar -x compileJava -x compileTestJava
--no-daemon
--scan
-Pversion=${{ format('{0}+{1}', env.VERSION, github.RUN_NUMBER) }}
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.token=${{ secrets.SONAR_TOKEN }}
-Dsonar.organization=${{ secrets.SONAR_KEY }}
-Dsonar.branch.name=${{ github.event.inputs.ref_name || github.REF_NAME}}
-Dsonar.qualitygate.wait=true
- name: Analyze code quality (PR)
if: startsWith(github.event_name, 'pull_request')
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a
with:
arguments: |
sonar -x compileJava -x compileTestJava
--no-daemon
--scan
-Pversion=${{ format('{0}+{1}', env.VERSION, github.RUN_NUMBER) }}
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.token=${{ secrets.SONAR_TOKEN }}
-Dsonar.organization=${{ secrets.SONAR_KEY }}
-Dsonar.pullrequest.branch=${{ github.HEAD_REF }}
-Dsonar.pullrequest.base=${{ github.BASE_REF }}
-Dsonar.pullrequest.key=${{ github.event.number }}
-Dsonar.qualitygate.wait=true