I spent hours to find out, why one of my junit tests runs local but not on the github workflow. The test which fails checks the existence of some files to do some configuration stuff. I'm using the maven-resources-plugin to copy these files to a folder inside the target directory. Here is my plugin setting of my pom.xml:
<plugin>
<!-- move some test resources to target -->
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resource-one</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/test-dir</outputDirectory>
<resources>
<resource>
<directory>${basedir}/test-files</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
The files are copied as expected and mvn clean test
runs as expected, but not within a github workflow.
Here is my workflow definition:
name: Sonar Scan
on:
push:
branches:
- develop
- feature*
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2.3.1
with:
distribution: 'adopt'
java-version: '11'
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=abckey
I guess this is a typically RTFM problem, but I didn't find anything.
Any hints?
UPDATE:
Just testet, mvn clean test
fails on github workflow too!