🔧 chore(migration): Create specificity to report generation #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarCloud8 | |
on: | |
push: | |
branches: | |
- "*" # This makes the workflow run on any branch | |
pull_request: | |
branches: | |
- "*" # This makes the workflow run on any PR | |
jobs: | |
build: | |
name: Build and analyze | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Clone the repository completely for analysis | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Clone the repository completely for analysis | |
# Step 2: Set up JDK 8 for the build | |
- name: Set up JDK 8 for build | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 8 | |
distribution: "temurin" | |
# Step 3: Remove default Maven and add Maven 3.8.1 | |
- name: Install Maven 3.8.1 | |
run: | | |
# Remove Maven if installed | |
sudo apt-get remove -y maven | |
# Download Maven 3.8.1 | |
wget https://archive.apache.org/dist/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz | |
# Extract the file | |
sudo tar -xvzf apache-maven-3.8.1-bin.tar.gz -C /opt | |
# Remove existing file in /usr/bin/mvn if it exists | |
sudo rm -f /usr/bin/mvn | |
# Create the symbolic link correctly | |
sudo ln -s /opt/apache-maven-3.8.1/bin/mvn /usr/bin/mvn | |
# Step 4: Clean Maven cache | |
- name: Clean Maven cache | |
run: rm -rf ~/.m2/repository # Clean local Maven cache | |
# Step 5: Force update of Maven dependencies and show details | |
- name: Clean and install dependencies | |
run: mvn clean install -U -X # Force update of dependencies and show error details. | |
# Step 6: Set up JDK 11 for SonarQube analysis | |
- name: Set up JDK 11 for SonarQube analysis | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 11 | |
distribution: "temurin" | |
# Step 7: Verify that the SonarCloud token is set | |
- name: Verify SONAR_TOKEN | |
run: | | |
if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then | |
echo "SONAR_TOKEN is not set or empty" | |
exit 1 | |
else | |
echo "SONAR_TOKEN is set" | |
fi | |
# Step 8: Build and analyze with SonarCloud | |
- name: Build and analyze with SonarCloud | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=CCAFS_MARLO -Dsonar.organization=ccafs -Dsonar.java.binaries=target/classes |