GitHub Eylemlerini Kullanarak Robot Kodu için CI kurmak

Bir ekip ortamında çalışmanın önemli bir yönü, GitHub gibi merkezi bir veri havuzuna gönderilen kodu test edebilmektir. Örneğin, proje yöneticisi veya baş geliştirici, kodu birleştirmeden önce bir dizi birim testi yapmak veya bir veri havuzunun ana dalındaki tüm kodların çalışır durumda olduğundan emin olmak isteyebilir.

GitHub Actions is a service that allows for teams and individuals to build and run unit tests on code on various branches and on pull requests. These types of services are more commonly known as “Continuous Integration” services. This tutorial will show you how to setup GitHub Actions on robot code projects.

Not

This tutorial assumes that your team’s robot code is being hosted on GitHub. For an introduction to Git and GitHub, please see this introduction guide.

Eylem oluşturma

CI sürecini gerçekleştirme talimatları bir YAML dosyasında depolanmaktadır. Bu dosyayı oluşturmak için, veri havuzunun sağ üstünde bulunan “Actions - Eylemler” sekmesine tıklayınınız. Ardından “set up a workflow yourself - iş akışı oluştur” bağlantısına tıklayınız.

Setup a workflow yourself.

Şimdi bir metin editörü ile karşılanacaksınız. Tüm varsayılan metni aşağıdakilerle değiştirin:

# 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:
  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 a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-22.04
    # This grabs the WPILib docker container
    container: wpilib/roborio-cross-ubuntu:2025-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@v6
    # 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: Compile and run tests on robot code
      run: ./gradlew build

Ardından, ekranın sağ üst köşesinde bulunan “Start commit-işlemeye başla” butonuna tıklayarak değişiklikleri kaydedin. İsterseniz varsayılan kaydetme mesajını düzenleyebilirsiniz. Sonrasında, “Commit new file-yeni dosya işle” yeşil butonuna tıklayın.

Committing a new file.

Ana bilgisayarda bir işlem gerçekleştiğinde, GitHub artık her zaman otomatik olarak çalıştıracaktır. Herhangi bir yapının durumunu izlemek için ekranın üst kısmındaki “ Actions -eylemler” sekmesine tıklayabilirsiniz.

View of the actions tab

Eylemler YAML Dosyasının Dökümü

İşte yukarıdaki YAML dosyasının bir dökümü. Her satırın tam olarak anlaşılması gerekmese de, bir miktar anlayış, daha fazla özellik eklemenize ve ortaya çıkabilecek olası sorunları gidermenize yardımcı olacaktır.

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch.
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

Bu kod bloğu, eylemin ne zaman çalışacağını belirler. Şu anda eylem, işlem yürütüldüğünde yada istendiğinde çalışacaktır.

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-22.04
    # This grabs the WPILib docker container
    container: wpilib/roborio-cross-ubuntu:2025-22.04

Her aksiyonun iş akışı, sıralı olarak (birbiri ardına) veya paralel (aynı anda) çalışan bir veya daha fazla işten oluşur. İş akışımızda sadece bir “yapım” işi vardır.

We specify that we want the job to run on an Ubuntu virtual machine and in a virtualized Docker container that contains the JDK, C++ compiler and roboRIO toolchains.

Not

Since none of the dependencies changed between 2025 and 2026, the 2025 docker images are still correct to use for 2026.

# 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@v6
# 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: Compile and run tests on robot code
  run: ./gradlew build

Each job has certain steps that will be executed. This job has four steps. The first step involves checking out the repository to access the robot code. The second step is a workaround for a GitHub Actions issue. The third step involves giving the virtual machine permission to execute gradle tasks using ./gradlew. The final step runs ./gradlew build to compile robot code and run any unit tests.

README.md Dosyasına Yapı Durum İşareti Ekleme

Main üzerinde en son derlemenin durumunu hızlı bir şekilde kontrol etmek için deponuzun README dosyasının üstüne bir CI durum işareti eklemek yararlıdır. Bunu yapmak için, ekranın üst kısmındaki “Actions-eylemler” sekmesine tıklayın ve ekranın sol tarafındaki “CI” sekmesini seçin. Ardından, sağ üstteki “Create status badge-durum işareti oluştur” düğmesini tıklayın ve durum işareti Markdown kodunu kopyalayın.

Where to click on "Copy status badge Markdown"

Son olarak, Kopyaladığınız Markdown kodunu README dosyanızın en üstüne yapıştırın, uygulayın ve değişikliklerinizi gönderin. Şimdi, ana depo sayfanızda GitHub Aksiyonları durum rozetini görmelisiniz.

A picture of the repository with the badge created.