Skip to content

Commit

Permalink
Merge pull request REVrobotics#14 from REVrobotics/github-actions
Browse files Browse the repository at this point in the history
Add GitHub Actions workflows for build and release
  • Loading branch information
Noah Andrews authored Apr 26, 2023
2 parents 4b8c216 + 4f8e0af commit a5d91d9
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 107 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build

on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'

defaults:
run:
shell: bash

jobs:
build:
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
container: ''
name: windows64
name: "build-${{ matrix.name }}"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.sha }}

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11

- name: Cache
uses: actions/cache@v3
with:
path: |
.gradle
bin
build
key: ${{ matrix.name }}-build-${{ github.sha }}
restore-keys: |
${{ matrix.name }}-build-
- name: Publish
run: |
./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode
# Put release files together in one directory
- name: Create Artifact
run: |
mkdir CANBridge-artifacts
cp -r build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib
cp -r build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.dll
cp -r build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib
# Upload build artifact
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: CANBridge-${{ github.sha }}
path: CANBridge-artifacts/

# Upload version.txt
- name: Upload version artifact
uses: actions/upload-artifact@v3
with:
name: version
path: build/allOutputs/version.txt
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Create release

on:
push:
tags:
- 'v*'

defaults:
run:
shell: bash

jobs:
check-versions:
runs-on: ubuntu-latest
outputs:
TAG_NAME: ${{ env.TAG_NAME }}
VERSION: ${{ steps.get_version.outputs.version }}
steps:
- name: Wait for build to finish
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: 'build-windows64'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Get tag name
run: |
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# Download artifacts from build workflow
- name: Download workflow artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{ github.sha }}
path: '.'

# Get publish.gradle version
- name: Get publish.gradle version
id: get_version
run: |
echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT
echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT
# Check publish.gradle version
- name: publish.gradle version check FAILED
if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }}
run: |
echo Tag name: ${{ env.TAG_NAME }}
echo publish.gradle version: ${{ steps.get_version.outputs.version }}
exit 1
prepare-release:
runs-on: ubuntu-latest
needs: check-versions
steps:
# Download API, docs, and version.txt
- name: Download workflow artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{ github.sha }}
path: './artifacts'

# Create new release draft
- name: Create release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ needs.check-versions.outputs.version }}
TAG=v$VERSION
gh release create $TAG --draft --title "Version $VERSION"
echo "Sleep after creating release to avoid race condition"
sleep 5
gh release upload $TAG CANBridge-${{ github.sha }}/*
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# RoboRIO SDK Readme
# CANBridge

## Overview

This respository is for the CANBridge software that is run on non-roboRIO platforms.
This repository is for the CANBridge software that is run on non-roboRIO platforms.

## Build Requirements

Expand All @@ -15,16 +15,28 @@ All of these, excluding Git, can be installed and configured with the [WPILib In

## Building and Publishing

Build and publish steps are done using the Gradle wrapper, `gradlew`. The Gradle wrapper is located in the root of the project, so Gradle commands must be run from there.
Building is done using the Gradle wrapper, `gradlew`. The Gradle wrapper is located in the root of the project, so Gradle commands must be run from there.

1. Clone this repository and open in VS Code
- When VS Code first opens, select `Add workspace folder...` underneath `Start` on the Welcome Screen
2. Open the VS Code terminal
- `View -> Terminal` or ``Ctrl+` ``
3. Run `./gradlew build` from root
4. Run `./gradlew publish` from root

The output folders will be generated under `~\releases\maven\`.
The output is placed at `~\releases\maven\release\com\revrobotics\usb\CANBridge-cpp\<version>\`.

### Publishing a new version

Before publishing a new version, run `./gradlew build` locally to run the tests. GitHub Actions
cannot run the tests because they depend on having a USB CAN device connected.

1. Bump the version number in `publish.gradle` and `CANBridge.json`
2. Commit the version bump
3. Create a new tag named `vX.X.X` at that commit
4. Push the tag to GitHub
5. Wait for the draft release to be created
6. Add release notes to the draft release
7. Publish the draft release

## Changelog

Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ plugins {
id 'cpp'
id 'java'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
id 'edu.wpi.first.NativeUtils' version '2020.7.2'
id 'edu.wpi.first.GradleJni' version '0.10.1'
id 'edu.wpi.first.GradleVsCode' version '0.12.0'
id 'edu.wpi.first.NativeUtils' version '2023.11.1'
id 'edu.wpi.first.GradleJni' version '1.1.0'
id 'edu.wpi.first.GradleVsCode' version '1.3.0'
id 'google-test-test-suite'
}

Expand Down Expand Up @@ -99,8 +99,8 @@ model {

binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio
|| it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian
|| it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
|| it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32
|| it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) {
it.buildable = false
}
// lib library: "SparkMaxDriver", linkage: 'shared'
Expand All @@ -113,5 +113,5 @@ model {
apply from: 'publish.gradle'

wrapper {
gradleVersion = '6.0.1'
gradleVersion = '7.5.1'
}
15 changes: 6 additions & 9 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import org.gradle.internal.os.OperatingSystem

nativeUtils.addWpiNativeUtils()
nativeUtils.withRoboRIO()
nativeUtils.withRaspbian()
nativeUtils.withBionic()
nativeUtils.withCrossRoboRIO()
nativeUtils.withCrossLinuxArm32()
nativeUtils.withCrossLinuxArm64()
nativeUtils {
wpi {
configureDependencies {
wpiVersion = "2020.+"
niLibVersion = "2020.9.1"
opencvVersion = "3.4.7-2"
googleTestVersion = "1.9.0-3-437e100"
wpiVersion = "2023.+"
niLibVersion = "2023.3.0"
googleTestVersion = "1.11.0-3"
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
dependencies {
implementation 'edu.wpi.first.cscore:cscore-java:2020.+'
implementation 'edu.wpi.first.cameraserver:cameraserver-java:2020.+'
implementation 'edu.wpi.first.ntcore:ntcore-java:2020.+'
implementation 'edu.wpi.first.wpilibj:wpilibj-java:2020.+'
implementation 'edu.wpi.first.wpiutil:wpiutil-java:2020.+'
implementation 'edu.wpi.first.hal:hal-java:2020.+'
implementation 'edu.wpi.first.thirdparty.frc2020.opencv:opencv-java:3.4.7-2'
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'maven-publish'

ext.licenseFile = files("$rootDir/LICENSE.txt")

def pubVersion = '2.0.1'
def pubVersion = '2.1.0'

def outputsFolder = file("$buildDir/allOutputs")

Expand Down
51 changes: 0 additions & 51 deletions src/main/java/com/revrobotics/jni/RevJNIWrapper.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/native/include/rev/Drivers/DriverDeviceThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,4 @@ class DriverDeviceThread {


} // namespace usb
} // namespace rev
} // namespace rev
15 changes: 8 additions & 7 deletions src/test/gtest/cpp/MockDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <wpi/Logger.h>
#include <wpi/SmallString.h>
#include <wpi/SmallVector.h>
#include <wpi/UDPClient.h>
#include <wpinet/UDPClient.h>
#include <wpi/raw_ostream.h>

#include <iostream>
Expand All @@ -28,16 +28,17 @@ static void LoggerFunc(unsigned int level, const char* file, unsigned int line,
return;
}

wpi::StringRef levelmsg;
oss << "DS: ";

if (level >= 50)
levelmsg = "CRITICAL: ";
oss << "CRITICAL: ";
else if (level >= 40)
levelmsg = "ERROR: ";
oss << "ERROR: ";
else if (level >= 30)
levelmsg = "WARNING: ";
oss << "WARNING: ";
else
return;
oss << "DS: " << levelmsg << msg << " (" << file << ':' << line << ")\n";
oss << msg << " (" << file << ":" << std::to_string(line) << ")\n";
wpi::errs() << oss.str();
}

Expand Down Expand Up @@ -102,4 +103,4 @@ void MockDS::enable() {

void MockDS::disable() {
m_enable = false;
}
}
Loading

0 comments on commit a5d91d9

Please sign in to comment.