From 655909cc84420eb0c30c7d4f97c99fae0e2a2a35 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 10 Jun 2024 21:37:01 -0400 Subject: [PATCH] Create combine job and offline vendordep ZIP (#1343) * Create combine job * Update build.yml * Bump max workers in photonlib * Oops * actually kill entirely * Maybe fix test * Don't run tests * Update OpenCVTest.java * Update build.yml * Use upload-artifact@v4 * Update build.yml * Update build.yml --- .github/workflows/build.yml | 65 +++++++++++++++++++++++++++----- build.gradle | 20 ++++++++++ docs/build.gradle | 11 +++++- photon-lib/build.gradle | 29 ++++++++++---- photon-server/netTest.json | 1 - photon-server/networktables.json | 1 - photon-server/test.json | 1 - shared/javacommon.gradle | 14 +++++-- shared/javacpp/publish.gradle | 15 +++++--- 9 files changed, 126 insertions(+), 31 deletions(-) delete mode 100644 photon-server/netTest.json delete mode 100644 photon-server/networktables.json delete mode 100644 photon-server/test.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e37f8a32..fcc75429e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,13 +55,13 @@ jobs: run: | chmod +x gradlew ./gradlew copyPhotonlib -x check - ./gradlew build -x check --max-workers 2 + ./gradlew build -x check - name: Build C++ examples working-directory: photonlib-cpp-examples run: | chmod +x gradlew ./gradlew copyPhotonlib -x check - ./gradlew build -x check --max-workers 2 + ./gradlew build -x check build-gradle: name: "Gradle Build" runs-on: ubuntu-22.04 @@ -83,11 +83,11 @@ jobs: - name: Gradle Build run: | chmod +x gradlew - ./gradlew photon-targeting:build photon-core:build photon-server:build -x check --max-workers 2 + ./gradlew photon-targeting:build photon-core:build photon-server:build -x check - name: Gradle Tests - run: ./gradlew testHeadless -i --max-workers 1 --stacktrace + run: ./gradlew testHeadless -i --stacktrace - name: Gradle Coverage - run: ./gradlew jacocoTestReport --max-workers 1 + run: ./gradlew jacocoTestReport - name: Publish Coverage Report uses: codecov/codecov-action@v3 with: @@ -115,7 +115,7 @@ jobs: - name: Build the docs run: | make html - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v4 with: name: built-docs path: build/html @@ -150,12 +150,19 @@ jobs: - run: git fetch --tags --force - run: | chmod +x gradlew - ./gradlew photon-targeting:build photon-lib:build --max-workers 1 + ./gradlew photon-targeting:build photon-lib:build -Pbuildalldesktop -i - run: ./gradlew photon-lib:publish photon-targeting:publish name: Publish env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} if: github.event_name == 'push' + # Copy artifacts to build/outputs/maven + - run: ./gradlew photon-lib:publish photon-targeting:publish outputVersion -PcopyOfflineArtifacts + - uses: actions/upload-artifact@v4 + with: + name: maven-${{ matrix.artifact-name }} + path: build/outputs + build-photonlib-docker: strategy: fail-fast: false @@ -163,10 +170,13 @@ jobs: include: - container: wpilib/roborio-cross-ubuntu:2024-22.04 artifact-name: Athena + build-options: "-Ponlylinuxathena" - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04 artifact-name: Raspbian + build-options: "-Ponlylinuxarm32" - container: wpilib/aarch64-cross-ubuntu:bullseye-22.04 artifact-name: Aarch64 + build-options: "-Ponlylinuxarm64" runs-on: ubuntu-22.04 container: ${{ matrix.container }} @@ -179,9 +189,10 @@ jobs: run: | git config --global --add safe.directory /__w/photonvision/photonvision - name: Build PhotonLib + # We don't need to run tests, since we specify only non-native platforms run: | chmod +x gradlew - ./gradlew photon-targeting:build photon-lib:build --max-workers 1 + ./gradlew photon-targeting:build photon-lib:build ${{ matrix.build-options }} -i -x test - name: Publish run: | chmod +x gradlew @@ -189,6 +200,38 @@ jobs: env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} if: github.event_name == 'push' + # Copy artifacts to build/outputs/maven + - run: ./gradlew photon-lib:publish photon-targeting:publish outputVersion -PcopyOfflineArtifacts + - uses: actions/upload-artifact@v4 + with: + name: maven-${{ matrix.artifact-name }} + path: build/outputs + + combine: + name: Combine + needs: [build-photonlib-docker, build-photonlib-host] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --tags --force + # download all maven-* artifacts to outputs/ + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: output + pattern: maven-* + - run: find . + - run: zip -r photonlib-$(git describe --tags --match=v*).zip . + name: ZIP stuff up + working-directory: output + - run: ls output + - uses: actions/upload-artifact@v4 + with: + name: photonlib-offline + path: output/*.zip + build-package: needs: [build-client, build-gradle, build-offline-docs] @@ -248,11 +291,11 @@ jobs: path: photon-server/src/main/resources/web/docs - run: | chmod +x gradlew - ./gradlew photon-server:shadowJar --max-workers 2 -PArchOverride=${{ matrix.arch-override }} + ./gradlew photon-server:shadowJar -PArchOverride=${{ matrix.arch-override }} if: ${{ (matrix.arch-override != 'none') }} - run: | chmod +x gradlew - ./gradlew photon-server:shadowJar --max-workers 2 + ./gradlew photon-server:shadowJar if: ${{ (matrix.arch-override == 'none') }} - uses: actions/upload-artifact@v4 with: @@ -428,6 +471,7 @@ jobs: **/*.xz **/*.jar **/photonlib*.json + **/photonlib*.zip if: github.event_name == 'push' # Upload all jars and xz archives - uses: softprops/action-gh-release@v1 @@ -436,6 +480,7 @@ jobs: **/*.xz **/*.jar **/photonlib*.json + **/photonlib*.zip if: startsWith(github.ref, 'refs/tags/v') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index f44dbe4ff..ce4517054 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,9 @@ allprojects { wpilibRepositories.addAllDevelopmentRepositories(it) } +ext.localMavenURL = file("$project.buildDir/outputs/maven") +ext.allOutputsFolder = file("$project.buildDir/outputs") + // Configure the version number. apply from: "versioningHelper.gradle" @@ -57,6 +60,23 @@ ext { println("Publishing Photonlib to " + photonMavenURL) } +task outputVersion() { + def versionFile = file("$allOutputsFolder/version.txt") + + description = 'Prints the versions of wpilib to a file for use by the downstream packaging project' + group = 'Build' + outputs.files(versionFile) + + doFirst { + buildDir.mkdir() + allOutputsFolder.mkdir() + } + + doLast { + versionFile.write versionString + } +} + spotless { java { target fileTree('.') { diff --git a/docs/build.gradle b/docs/build.gradle index f6ce18219..925c77ae4 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -13,11 +13,11 @@ evaluationDependsOn ':photon-lib' def baseArtifactIdCpp = 'documentation' -def artifactGroupIdCpp = 'org.photonvision.wpilibc' +def artifactGroupIdCpp = 'org.photonvision.cppdocs' def zipBaseNameCpp = '_GROUP_org.photonvision_cpp_ID_documentation_CLS' def baseArtifactIdJava = 'documentation' -def artifactGroupIdJava = 'org.photonvision.wpilibj' +def artifactGroupIdJava = 'org.photonvision.javadocs' def zipBaseNameJava = '_GROUP_org.photonvision_java_ID_documentation_CLS' def outputsFolder = file("$project.buildDir/outputs") @@ -284,4 +284,11 @@ publishing { version pubVersion } } + + repositories { + maven { + // Just throw everything into build/maven + url(localMavenURL) + } + } } diff --git a/photon-lib/build.gradle b/photon-lib/build.gradle index 63ea46198..d8e990b7e 100644 --- a/photon-lib/build.gradle +++ b/photon-lib/build.gradle @@ -161,6 +161,18 @@ task generateVendorJson() { build.mustRunAfter generateVendorJson publish.mustRunAfter generateVendorJson +task publishVendorJsonToLocalOutputs(type: Copy) { + from photonlibFileOutput + into "$allOutputsFolder/vendordeps/" + + // Rename to match the name of the JSON we publish to maven to avoid user confusion + rename { String fileName -> + fileName.replace(".json", "-json-1.0.json") + } + + publish.dependsOn it +} + task writeCurrentVersion { def versionFileIn = file("${rootDir}/shared/PhotonVersion.java.in") writePhotonVersionFile(versionFileIn, Path.of("$projectDir", "src", "main", "java", "org", "photonvision", "PhotonVersion.java"), @@ -203,7 +215,7 @@ model { def vendorJson = artifacts.add('archives', file("$photonlibFileOutput")) -model { +if (!project.hasProperty('copyOfflineArtifacts')) { // Publish the vendordep json publishing { publications { @@ -269,13 +281,16 @@ task combinedHeadersZip(type: Zip) { // Add the uberzip to our maven publications publishing { publications { - combinedcpp(MavenPublication) { - artifact combinedCppSourcesZip - artifact combinedHeadersZip + // Don't publish if we're creating an offline zip + if (!project.hasProperty('copyOfflineArtifacts')) { + combinedcpp(MavenPublication) { + artifact combinedCppSourcesZip + artifact combinedHeadersZip - artifactId = "${nativeName}-combinedcpp" - groupId artifactGroupId - version pubVersion + artifactId = "${nativeName}-combinedcpp" + groupId artifactGroupId + version pubVersion + } } } } diff --git a/photon-server/netTest.json b/photon-server/netTest.json deleted file mode 100644 index 56a12f282..000000000 --- a/photon-server/netTest.json +++ /dev/null @@ -1 +0,0 @@ -{"ntServerAddress":"","connectionType":"DHCP","staticIp":"","hostname":"photonvision","runNTServer":false,"shouldManage":false} diff --git a/photon-server/networktables.json b/photon-server/networktables.json deleted file mode 100644 index fe51488c7..000000000 --- a/photon-server/networktables.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/photon-server/test.json b/photon-server/test.json deleted file mode 100644 index 173b493aa..000000000 --- a/photon-server/test.json +++ /dev/null @@ -1 +0,0 @@ -{"baseName":"aaaaaa","uniqueName":"aaaaaa","nickname":"aaaaaa","FOV":70.0,"path":"dev/vid","cameraType":"UsbCamera","currentPipelineIndex":0,"camPitch":{"radians":0.0},"calibrations":[], "cameraLEDs":[]} diff --git a/shared/javacommon.gradle b/shared/javacommon.gradle index 14ea2753d..4cfe76bfd 100644 --- a/shared/javacommon.gradle +++ b/shared/javacommon.gradle @@ -79,10 +79,16 @@ publishing { repositories { maven { - url(photonMavenURL) - credentials { - username 'ghactions' - password System.getenv("ARTIFACTORY_API_KEY") + // If we're trying to copy local outputs, just throw everything into build/maven + // The problem here is we can't specify which repo to publish to easily, so we have to choose one or the other + if (project.hasProperty('copyOfflineArtifacts')) { + url(localMavenURL) + } else { + url(photonMavenURL) + credentials { + username 'ghactions' + password System.getenv("ARTIFACTORY_API_KEY") + } } } } diff --git a/shared/javacpp/publish.gradle b/shared/javacpp/publish.gradle index 9c7edbd70..860bf248e 100644 --- a/shared/javacpp/publish.gradle +++ b/shared/javacpp/publish.gradle @@ -21,7 +21,6 @@ task cppSourcesZip(type: Zip) { into '/' } - println("Sources: from $projectDir ") from("$projectDir/src/main/native/cpp") { into '/' } @@ -91,10 +90,16 @@ model { repositories { maven { - url(photonMavenURL) - credentials { - username 'ghactions' - password System.getenv("ARTIFACTORY_API_KEY") + // If we're trying to copy local outputs, just throw everything into build/maven + // The problem here is we can't specify which repo to publish to easily, so we have to choose one or the other + if (project.hasProperty('copyOfflineArtifacts')) { + url(localMavenURL) + } else { + url(photonMavenURL) + credentials { + username 'ghactions' + password System.getenv("ARTIFACTORY_API_KEY") + } } } }