SCSCANGHA-6 Add Github Actions tests
This commit is contained in:
parent
19888635fa
commit
0861f01544
7 changed files with 148 additions and 1 deletions
128
.github/workflows/qa.yml
vendored
Normal file
128
.github/workflows/qa.yml
vendored
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
name: QA
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
argsInputTest:
|
||||
name: >
|
||||
'args' input
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run action with args
|
||||
uses: ./
|
||||
with:
|
||||
args: -Dsonar.someArg=aValue -Dsonar.scanner.dumpToFile=./output.properties
|
||||
env:
|
||||
SONAR_TOKEN: FAKE_TOKEN
|
||||
- name: Assert
|
||||
run: |
|
||||
./test/assertFileContains ./output.properties "sonar.someArg=aValue"
|
||||
projectBaseDirInputTest:
|
||||
name: >
|
||||
'projectBaseDir' input
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: |
|
||||
mkdir -p ./baseDir
|
||||
- name: Run action with projectBaseDir
|
||||
uses: ./
|
||||
with:
|
||||
args: -Dsonar.scanner.dumpToFile=./output.properties
|
||||
projectBaseDir: ./baseDir
|
||||
env:
|
||||
SONAR_TOKEN: FAKE_TOKEN
|
||||
- name: Assert
|
||||
run: |
|
||||
./test/assertFileContains ./output.properties "sonar.projectBaseDir=.*/baseDir"
|
||||
sonarTokenRequiredTest:
|
||||
name: >
|
||||
'SONAR_TOKEN' env var required
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run action without SONAR_TOKEN
|
||||
uses: ./
|
||||
with:
|
||||
args: -Dsonar.scanner.dumpToFile=./output.properties
|
||||
continue-on-error: true
|
||||
- name: Previous should have failed
|
||||
if: ${{ steps.runTest.outcome == 'success'}}
|
||||
run: |
|
||||
echo "Expected previous step to fail"
|
||||
exit 1
|
||||
failFastGradleTest:
|
||||
name: >
|
||||
Fail fast on Gradle project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run action on Gradle project
|
||||
id: runTest
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
env:
|
||||
SONAR_TOKEN: FAKE_TOKEN
|
||||
with:
|
||||
projectBaseDir: ./test/gradle-project
|
||||
- name: Previous should have failed
|
||||
if: ${{ steps.runTest.outcome == 'success'}}
|
||||
run: |
|
||||
echo "Expected previous step to fail"
|
||||
exit 1
|
||||
failFastGradleKotlinTest:
|
||||
name: >
|
||||
Fail fast on Kotlin Gradle project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run action on Kotlin Gradle project
|
||||
id: runTest
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
env:
|
||||
SONAR_TOKEN: FAKE_TOKEN
|
||||
with:
|
||||
projectBaseDir: ./test/gradle-project-kotlin
|
||||
- name: Previous should have failed
|
||||
if: ${{ steps.runTest.outcome == 'success'}}
|
||||
run: |
|
||||
echo "Expected previous step to fail"
|
||||
exit 1
|
||||
failFastMavenTest:
|
||||
name: >
|
||||
Fail fast on Maven project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run action on Maven project
|
||||
id: runTest
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
env:
|
||||
SONAR_TOKEN: FAKE_TOKEN
|
||||
with:
|
||||
projectBaseDir: ./test/maven-project
|
||||
- name: Previous should have failed
|
||||
if: ${{ steps.runTest.outcome == 'success'}}
|
||||
run: |
|
||||
echo "Expected previous step to fail"
|
||||
exit 1
|
||||
|
|
@ -25,4 +25,3 @@ RUN chmod +x /entrypoint.sh
|
|||
COPY cleanup.sh /cleanup.sh
|
||||
RUN chmod +x /cleanup.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
|
|
|
|||
10
test/assertFileContains
Executable file
10
test/assertFileContains
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
error() { echo -e "\\e[31m✗ $*\\e[0m"; }
|
||||
|
||||
assertFileExists $1
|
||||
|
||||
if ! grep -q $2 $1; then
|
||||
error "'$2' not found in '$1'"
|
||||
exit 1
|
||||
fi
|
||||
8
test/assertFileExists
Executable file
8
test/assertFileExists
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
error() { echo -e "\\e[31m✗ $*\\e[0m"; }
|
||||
|
||||
if [ ! -f $1 ]; then
|
||||
error "File '$1' not found"
|
||||
exit 1
|
||||
fi
|
||||
0
test/gradle-project-kotlin/build.gradle.kts
Normal file
0
test/gradle-project-kotlin/build.gradle.kts
Normal file
1
test/gradle-project/build.gradle
Normal file
1
test/gradle-project/build.gradle
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
test/maven-project/pom.xml
Normal file
1
test/maven-project/pom.xml
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
Loading…
Add table
Add a link
Reference in a new issue