From 95b9c928d646d9f8578353fa1f684610f4fa01a4 Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Sat, 22 Jun 2024 10:42:11 -0700 Subject: [PATCH] Add GitHub Actions Workflow (#603) * Add GitHub Actions Workflow Remove Azure & Travis CI Update README badge Upload test results report --------- Co-authored-by: Austin Shalit --- .github/workflows/ci.yml | 119 ++++++++++++++++ .../workflows/gradle-wrapper-validation.yml | 10 -- README.md | 2 +- azure-pipelines.yml | 127 ------------------ .../robotbuilder/exporters/CppExportTest.java | 2 +- 5 files changed, 121 insertions(+), 139 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/gradle-wrapper-validation.yml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..30fc3573 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,119 @@ +name: CI + +on: [pull_request, push] + +jobs: + test-docker: + strategy: + fail-fast: false + matrix: + include: + - container: wpilib/roborio-cross-ubuntu:2024-22.04 + artifact-name: Linux + name: "Test - ${{ matrix.artifact-name }}" + runs-on: ubuntu-latest + container: ${{ matrix.container }} + env: + DISPLAY: ':10' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: gradle/actions/wrapper-validation@v3 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Install and start xvfb + run: | + sudo apt-get update + sudo apt-get install -y xvfb + Xvfb $DISPLAY & + - name: Check + run: ./gradlew check -PbuildServer + - name: ${{ matrix.artifact-name }} Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + build/test-results/test/TEST*.xml + - name: ${{ matrix.artifact-name }} Upload Test Results + uses: actions/upload-artifact@v4 + if: always() + with: + name: ${{ matrix.artifact-name }}TestReport + path: | + build/reports/ + + test-host: + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + artifact-name: Win64 + architecture: x64 + - os: macos-12 + artifact-name: macOS + architecture: x64 + name: "Test - ${{ matrix.artifact-name }}" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: gradle/actions/wrapper-validation@v3 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + architecture: ${{ matrix.architecture }} + - name: Check + run: ./gradlew check -PbuildServer + - name: ${{ matrix.artifact-name }} Upload Test Results + uses: actions/upload-artifact@v4 + if: always() + with: + name: ${{ matrix.artifact-name }}TestReport + path: | + build/reports/ + + publish: + name: Publish + needs: [test-docker, test-host] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Publish + if: | + !startsWith(github.ref, 'refs/tags/v') && + github.ref != 'refs/heads/master' + run: ./gradlew publish -PbuildServer + - name: Publish (Master) + if: | + github.repository_owner == 'wpilibsuite' && + github.ref == 'refs/heads/master' + run: ./gradlew publish -PbuildServer + env: + RUN_AZURE_ARTIFACTORY_RELEASE: 'TRUE' + ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + - name: Publish (Release) + if: | + github.repository_owner == 'wpilibsuite' && + startsWith(github.ref, 'refs/tags/v') + run: ./gradlew publish -PbuildServer -PreleaseMode + env: + RUN_AZURE_ARTIFACTORY_RELEASE: 'TRUE' + ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + - uses: actions/upload-artifact@v4 + with: + name: RobotBuilder + path: build/libs/RobotBuilder-all.jar diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml deleted file mode 100644 index 95cce8ba..00000000 --- a/.github/workflows/gradle-wrapper-validation.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: "Validate Gradle Wrapper" -on: [push, pull_request] - -jobs: - validation: - name: "Validation" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v2 diff --git a/README.md b/README.md index b7a01d53..76309b8d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # RobotBuilder Project -[![Build Status](https://dev.azure.com/wpilib/DesktopTools/_apis/build/status/wpilibsuite.RobotBuilder)](https://dev.azure.com/wpilib/DesktopTools/_build/latest?definitionId=13) +[![CI](https://github.com/wpilibsuite/RobotBuilder/actions/workflows/ci.yml/badge.svg)](https://github.com/wpilibsuite/RobotBuilder/actions/workflows/ci.yml) Welcome to the WPILib project. This repository contains the RobotBuilder project. This program can be used to automatically generate Java and C++ FRC programs using the [New Command Framework](https://docs.wpilib.org/en/stable/docs/software/commandbased/index.html). diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 28d070f3..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,127 +0,0 @@ -# Gradle -# Build your Java project and run tests with Gradle using a Gradle wrapper script. -# Add steps that analyze code, save build artifacts, deploy, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/java - -resources: - containers: - - container: wpilib2024 - image: wpilib/roborio-cross-ubuntu:2024-22.04 - -variables: -- group: Artifactory-Package-Publish - -stages: -- stage: Build - jobs: - - job: Linux - pool: - vmImage: 'ubuntu-22.04' - - container: wpilib2024 - - variables: - DISPLAY: ':10' - MACOSX_DEPLOYMENT_TARGET: 11 - - steps: - - bash: | - sudo apt-get update - sudo apt-get install -y xvfb - Xvfb :10 & - displayName: 'Install and start xvfb' - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - gradleOptions: '-Xmx3072m' - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - testRunTitle: Linux - tasks: 'check' - options: '-PbuildServer' - - - job: Windows_64_Bit - pool: - vmImage: 'windows-2022' - - steps: - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - gradleOptions: '-Xmx3072m' - jdkVersionOption: '1.17' - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - testRunTitle: Win64 - tasks: 'check' - options: '-PbuildServer' - - - job: Mac - pool: - vmImage: 'macOS-12' - steps: - - script: | - mkdir build - export JAVA_HOME=`/usr/libexec/java_home -v 17` - displayName: 'Setup JDK' - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - gradleOptions: '-Xmx3072m' - jdkVersionOption: '1.17' - publishJUnitResults: true - testResultsFiles: '**/TEST-*.xml' - testRunTitle: MacOS - tasks: 'check' - options: '-PbuildServer' - -- stage: Publish - jobs: - - job: PublishJob - pool: - vmImage: 'ubuntu-22.04' - - steps: -# PR Builds - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - gradleOptions: '-Xmx3072m' - jdkVersionOption: '1.17' - tasks: 'publish' - options: '-PbuildServer' - condition: and(succeeded(), and(ne(variables['Build.SourceBranch'], 'refs/heads/main'), not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')))) - -# Main Builds - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - gradleOptions: '-Xmx3072m' - jdkVersionOption: '1.17' - tasks: 'publish' - options: '-PbuildServer' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) - env: - RUN_AZURE_ARTIFACTORY_RELEASE: 'TRUE' - ARTIFACTORY_PUBLISH_USERNAME: $(PublishUserName) - ARTIFACTORY_PUBLISH_PASSWORD: $(PublishPassword) - -# Tagged Builds - - task: Gradle@2 - inputs: - workingDirectory: '' - gradleWrapperFile: 'gradlew' - jdkVersionOption: '1.17' - gradleOptions: '-Xmx3072m' - tasks: 'publish ' - options: '-PreleaseMode -PbuildServer' - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) - env: - RUN_AZURE_ARTIFACTORY_RELEASE: 'TRUE' - ARTIFACTORY_PUBLISH_USERNAME: $(PublishUserName) - ARTIFACTORY_PUBLISH_PASSWORD: $(PublishPassword) diff --git a/src/test/java/robotbuilder/exporters/CppExportTest.java b/src/test/java/robotbuilder/exporters/CppExportTest.java index dc2acb06..f89bdec0 100644 --- a/src/test/java/robotbuilder/exporters/CppExportTest.java +++ b/src/test/java/robotbuilder/exporters/CppExportTest.java @@ -47,7 +47,7 @@ public void setUp() { public void tearDown() { System.gc(); File project = new File("build/test-resources/" + PROJECT_DIRECTORY); - TestUtils.delete(project); + //TestUtils.delete(project); } @Test