Skip to content

Commit e7a2c68

Browse files
committed
Add ci pipelines for build/test and code linting
1 parent b2b551d commit e7a2c68

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

.github/workflows/build_test.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Micro Autonomy Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
setup-environment:
14+
name: Setup Environment
15+
runs-on: ubuntu-latest
16+
17+
outputs:
18+
docker_matrix: ${{ steps.docker-environment.outputs.docker_matrix }}
19+
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
24+
- name: Generate Docker Environment
25+
id: docker-environment
26+
run: |
27+
# Create static matrix for F1TENTH services (single line JSON)
28+
matrix='{"include":[{"service":"robot","dockerfile":"docker/robot/robot.Dockerfile","compose_file":"modules/docker-compose.robot.yaml"},{"service":"sim","dockerfile":"docker/sim/sim.Dockerfile","compose_file":"modules/docker-compose.sim.yaml"},{"service":"vis_tools","dockerfile":"docker/vis_tools/foxglove.Dockerfile","compose_file":"modules/docker-compose.vis_tools.yaml"},{"service":"samples","dockerfile":"docker/samples/py_producer.Dockerfile","compose_file":"modules/docker-compose.samples.yaml"}]}'
29+
echo "docker_matrix=$matrix" >> $GITHUB_OUTPUT
30+
31+
build-and-unittest:
32+
name: Build/Test
33+
runs-on: ubuntu-latest
34+
needs: setup-environment
35+
36+
env:
37+
SAMPLES_PRODUCER_IMAGE: "samples-producer:latest"
38+
SAMPLES_TRANSFORMER_IMAGE: "samples-transformer:latest"
39+
SAMPLES_AGGREGATOR_IMAGE: "samples-aggregator:latest"
40+
ROBOT_IMAGE: "robot:latest"
41+
INFRASTRUCTURE_FOXGLOVE_IMAGE: "infrastructure-foxglove:latest"
42+
FOXGLOVE_BRIDGE_PORT: "9090"
43+
SIM_IMAGE: "sim:latest"
44+
SIM_AUTODRIVE_IMAGE: "sim-autodrive:latest"
45+
46+
strategy:
47+
fail-fast: false
48+
matrix: ${{ fromJSON(needs.setup-environment.outputs.docker_matrix) }}
49+
50+
concurrency:
51+
group: ${{ matrix.service }}-${{ github.workflow }}-${{ github.ref }}
52+
cancel-in-progress: true
53+
54+
steps:
55+
- name: Checkout repository
56+
uses: actions/checkout@v4
57+
58+
- name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v3
60+
id: buildx
61+
62+
- name: Build Image from Source
63+
run: |
64+
# Build using Docker Compose with all env vars available
65+
docker compose -f ${{ matrix.compose_file }} build
66+
env:
67+
DOCKER_BUILDKIT: 1
68+
COMPOSE_DOCKER_CLI_BUILD: 1
69+
BUILDKIT_INLINE_CACHE: 1
70+
71+
confirm-build-and-unittest-complete:
72+
name: Check Build/Test Completion
73+
needs: build-and-unittest
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Ending
77+
run: |
78+
echo "all builds and unit tests completed."

.github/workflows/linting_auto.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Code Linting - Auto Linter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
types:
11+
- unlabeled
12+
- labeled
13+
- synchronize
14+
15+
jobs:
16+
run-linters:
17+
name: Run C++/Python linters
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Check out Git repository
22+
uses: actions/checkout@v4
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v1
28+
with:
29+
python-version: 3.9.22
30+
31+
- name: Install Python dependencies
32+
run: pip install autopep8 clang-format
33+
34+
- name: Run linters, make changes
35+
continue-on-error: true
36+
uses: WATonomous/wato-lint-action@v1
37+
with:
38+
auto_fix: ${{ contains(github.event.pull_request.labels.*.name, 'auto-lint') }}
39+
Autopep8: true
40+
Autopep8_args: "--max-line-length 100"
41+
clang_format: true
42+
clang_format_auto_fix: ${{ contains(github.event.pull_request.labels.*.name, 'auto-lint') }}
43+
clang_format_args: "-style=file"
44+
45+
- name: Remove 'auto-lint' label to stop possible inf loop
46+
if: contains(github.event.pull_request.labels.*.name, 'auto-lint')
47+
uses: actions/github-script@v6
48+
with:
49+
script: |
50+
await github.rest.issues.removeLabel({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
issue_number: context.issue.number,
54+
name: 'auto-lint'
55+
});

0 commit comments

Comments
 (0)