[GS] Add Imperial Units #378
Workflow file for this run
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
name: Merge Criteria | |
on: | |
pull_request: | |
push: | |
branches: main | |
workflow_dispatch: | |
inputs: | |
commit_sha: | |
description: 'Commit SHA to build' | |
required: false | |
type: string | |
jobs: | |
generate_matrix: | |
name: Generate Matrix | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.commit_sha || github.event.pull_request.head.sha || github.sha }} | |
- name: Get changed directories | |
id: changed-files | |
uses: tj-actions/changed-files@v37 | |
with: | |
dir_names: 'true' | |
dir_names_max_depth: '1' | |
json: 'true' | |
escape_json: 'false' | |
- name: Filter changed directories | |
id: changed-files-filtered | |
# The build pipeline is triggered only for the project in which the changes happened. | |
# For example if a change was made in flight_computer/src/main.cpp, a pipeline will | |
# run only for the 'flight_computer' project. | |
# | |
# If changes happened at the root of the repository, or in .github/, the pipeline will | |
# run for all three projects. | |
# Additionally, the pipeline will also run for all three projects if it is triggered | |
# when pushing to main. | |
run: | | |
contains_dot=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq 'map(select(. == ".")) | length') | |
contains_dotgithub=$(echo '${{ steps.changed-files.outputs.all_changed_files }}' | jq 'map(select(. == ".github")) | length') | |
is_manual_trigger=$(echo '${{ github.event.inputs.commit_sha }}') | |
if [[ -n "$is_manual_trigger" || "${GITHUB_REF}" == "refs/heads/main" || $contains_dot -gt 0 || $contains_dotgithub -gt 0 ]]; then | |
filtered_array='["flight_computer","ground_station","telemetry"]' | |
else | |
filtered_array='${{ steps.changed-files.outputs.all_changed_files }}' | |
fi | |
echo "$filtered_array" | |
echo "matrix=$filtered_array" >> "$GITHUB_OUTPUT" | |
outputs: | |
matrix: ${{ steps.changed-files-filtered.outputs.matrix }} | |
format_check: | |
if: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} | |
name: Format Check | |
needs: generate_matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Run clang-format | |
uses: jidicula/[email protected] | |
with: | |
clang-format-version: '17' | |
check-path: '${{ matrix.project }}/src' | |
exclude-regex: '(lib|telemetry/src/st)' | |
build_lint: | |
if: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} | |
needs: [generate_matrix, format_check] | |
name: '[Ubuntu] Build + Lint' | |
# We are linting on Ubuntu because the linter seems to work better on Linux | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.platformio/.cache | |
# Add OS to key if testing with multiple OSes | |
key: ${{ matrix.project }}-pio | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.9' | |
cache: 'pip' | |
- name: Install dependencies | |
run: pip install --upgrade platformio | |
- name: Install PlatformIO Libraries | |
run: pio pkg install --global | |
- name: Build | |
shell: bash | |
run: | | |
if [[ "${{ matrix.project }}" == "flight_computer" ]]; then | |
platformio run -d ${{ matrix.project }} --environment debug | |
else | |
platformio run -d ${{ matrix.project }} | |
fi | |
- name: Generate compile_commands.json | |
run: | | |
if [[ "${{ matrix.project }}" == "flight_computer" ]]; then | |
platformio run -d ${{ matrix.project }} --target compiledb --environment debug | |
else | |
platformio run -d ${{ matrix.project }} --target compiledb | |
fi | |
- name: Lint | |
working-directory: ./${{ matrix.project }} | |
run: | | |
if [[ "${{ matrix.project }}" == "flight_computer" ]]; then | |
output=$(platformio check --environment debug) | |
else | |
output=$(platformio check) | |
fi | |
echo "$output" | |
echo "Note: Warnings 'clang-diagnostic-c++17-extensions' and 'clang-analyzer-valist.Uninitialized' are excluded from checking since they seem to be false-positives. Fix everything else!" | |
# filter the output to exclude false positives | |
filtered_output=$(echo "$output" | grep -vE 'clang-diagnostic-c\+\+17-extensions|clang-analyzer-valist.Uninitialized') | |
if echo "$filtered_output" | grep -q "warning"; then | |
echo "clang-tidy check failed!" | |
exit 1 | |
fi | |
- name: Upload Compile Commands | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ubuntu_compile_commands | |
path: | | |
./${{ matrix.project }}/.pio/build/**/compile_commands.json | |
if-no-files-found: error | |
retention-days: 90 | |
build_upload: | |
if: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} | |
needs: [generate_matrix, format_check] | |
name: '[Windows] Build + Upload' | |
# We are running this on windows because the users get binaries compiled on windows. | |
runs-on: windows-latest | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.platformio/.cache | |
# Add OS to key if testing with multiple OSes | |
key: ${{ matrix.project }}-pio | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.9' | |
cache: 'pip' | |
- name: Install dependencies | |
run: pip install --upgrade platformio | |
- name: Install PlatformIO Libraries | |
run: pio pkg install --global | |
- name: Build | |
shell: bash | |
run: | | |
platformio run -d ${{ matrix.project }} | |
if [[ "${{ matrix.project }}" == "ground_station" ]]; then | |
python ${{ matrix.project }}/uf2_loader.py ${{ matrix.project }}/.pio/build/ground_station/firmware | |
fi | |
- name: Generate compile_commands.json | |
run: platformio run -d ${{ matrix.project }} --target compiledb | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts | |
path: | | |
./${{ matrix.project }}/.pio/build/**/firmware.UF2 | |
./${{ matrix.project }}/.pio/build/**/firmware.bin | |
./${{ matrix.project }}/.pio/build/**/firmware.elf | |
./${{ matrix.project }}/.pio/build/**/compile_commands.json | |
if-no-files-found: error | |
retention-days: 90 |