Merge pull request #5 from 4201VitruvianBots/merge-2024driveTrain #7
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
# This is a basic workflow to build robot code. | |
name: CI | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the main branch. | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains two jobs, one for testing build and simulation, and one for automatically applying spotless | |
spotless: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# This grabs the WPILib docker container | |
container: wpilib/roborio-cross-ubuntu:2024-22.04 | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{secrets.BOT_ACCESS_TOKEN}} | |
# Declares the repository safe and not under dubious ownership. | |
- name: Add repository to git safe directories | |
run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
# Logs into our 4201 actions bot | |
- name: Setup Git | |
run: | | |
git config user.name "4201-actions-bot" | |
git config user.email "[email protected]" | |
# Grant execute permission for gradlew | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# Runs a single command using the runners shell | |
- name: Applying spotless formatting | |
run: ./gradlew spotlessApply | |
# Runs a single command using the runners shell | |
- name: Commiting changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Automatically applied spotless | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# This grabs the WPILib docker container | |
container: wpilib/roborio-cross-ubuntu:2024-22.04 | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# Declares the repository safe and not under dubious ownership. | |
- name: Add repository to git safe directories | |
run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
# Grant execute permission for gradlew | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# Runs a single command using the runners shell | |
- name: Applying spotless formatting | |
run: ./gradlew spotlessApply | |
# Runs a single command using the runners shell | |
- name: Compile and run tests on robot code | |
run: ./gradlew build -x test | |
# Runs a single command using the runners shell | |
- name: Run the robot code in a simulator | |
run: timeout 30 ./gradlew simulateJava || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi |