Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Bump actions/checkout from 3 to 4 #7

Bump actions/checkout from 3 to 4

Bump actions/checkout from 3 to 4 #7

Workflow file for this run

# Continuous Integration tests
name: NUbots CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
# Triggers on PRs to any branch
pull_request:
# Trigger for merge queue
merge_group:
types: [checks_requested]
# Ensure that only one instance of the workflow is run at a time for each branch/tag.
# Jobs currently running on the branch/tag will be cancelled when new commits are pushed.
# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency.
concurrency:
# `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier
group: ${{ format('{0}:{1}', github.workflow, github.ref) }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Detects changes to NUbots related files, for conditionally running other jobs
check_for_changes:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Output the detected changes for conditionally running other jobs
outputs:
has_workflow_changes: ${{ steps.filter.outputs.workflow_changes }}
has_docker_changes: ${{ steps.filter.outputs.docker_changes }}
has_code_changes: ${{ steps.filter.outputs.code_changes }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Check for NUbots Changes
uses: dorny/paths-filter@v2
id: filter
with:
# Considers any non-NUsight and non-VSCode config change to be a NUbots change
filters: |
workflow_changes:
- '.github/workflows/nubots.yaml'
docker_changes:
- 'docker/**'
code_changes:
- '{module,shared,nuclear}/**'
- 'CMakeLists.txt'
# Build the docker image. This job is not conditional since we don't want it skipped
# because other jobs depend on it. The actual building of the image is cached, so it
# wont't be doing unnecessary work if there are no relevant Dockerfile changes.
build_docker:
name: "Build docker image"
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# We output the image tag that we create so the other jobs can use it
outputs:
image: ${{ steps.image_output.outputs.image }}
# 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
- name: Checkout Code
uses: actions/checkout@v4
# Setup docker buildx
- name: 🐳 Set up docker buildx 🐳
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# Build the docker image
- name: 🐳 Build the docker image 🐳
uses: docker/[email protected]
with:
pull: true
tags: "nubots/nubots:pull-request-${{ github.event.number }}"
file: docker/Dockerfile
context: docker
build-args: |
platform=generic
BUILDKIT_INLINE_CACHE=1
push: true
cache-from: |
type=registry,ref=nubots/nubots:pull-request-${{ github.event.number }}
type=registry,ref=nubots/nubots:generic
type=inline
- id: image_output
name: Output the created image
run: echo "::set-output name=image::nubots/nubots:pull-request-${{ github.event.number }}"
# Build the codebase
build_nubots:
name: "Build and test NUbots"
needs: [check_for_changes, build_docker]
# Run only if the workflow or NUbots related code files have changed
if: >
needs.check_for_changes.outputs.has_workflow_changes == 'true' ||
needs.check_for_changes.outputs.has_docker_changes == 'true' ||
needs.check_for_changes.outputs.has_code_changes == 'true'
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Run on the container we just built
container:
image: "${{ needs.build_docker.outputs.image }}"
options: --user 0:0
# 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
- name: Checkout Code
uses: actions/checkout@v4
- name: Prepare Build Directory
run: mkdir -p ../build
- name: Configure the code
run: ./b configure -- -DBUILD_TESTS=ON # -DCI_BUILD=ON
- name: Build the code
run: ./b build
- name: Test the code
run: ./b tests run
# Check that the code is formatted correctly
check-format:
name: "Check Code Formatting"
needs: [check_for_changes, build_docker]
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Run on the container we just built
container:
image: "${{ needs.build_docker.outputs.image }}"
options: --user 0:0
# 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
- name: Checkout Code
uses: actions/checkout@v4
- name: Check formatting
run: ./b format --check --all --verbose