Skip to content

Commit

Permalink
Merge commit 'ca1ee9d2da2a488b1a40b811b069f3b681ede26f' as 'src/note-c'
Browse files Browse the repository at this point in the history
  • Loading branch information
zfields committed Jun 21, 2024
2 parents 98a204f + ca1ee9d commit 9fa88c9
Show file tree
Hide file tree
Showing 190 changed files with 44,037 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/note-c/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/docker-existing-dockerfile
{
"name": "Note-C Development Environment Dockerfile",

// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",

// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"image": "ghcr.io/blues/note_c_ci:latest",
// "dockerFile": "../Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"shardulm94.trailing-spaces",
"twxs.cmake"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [
// "--device=/dev/bus/usb/"
// ],

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "blues"
}
17 changes: 17 additions & 0 deletions src/note-c/.github/actions/load-ci-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Load note-c CI Docker image'
runs:
using: 'composite'
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Download image artifact
uses: actions/download-artifact@v3
with:
name: note_c_ci_image
path: /tmp

- name: Load Docker image
shell: bash
run: |
docker load --input /tmp/note_c_ci_image.tar
183 changes: 183 additions & 0 deletions src/note-c/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: note-c CI Pipeline

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
check_dockerfile_changed:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}

steps:
- name: Checkout code
uses: actions/checkout@v3

# TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd
# use something more "official".
- name: Check if Dockerfile changed
uses: dorny/paths-filter@v2
id: filter
with:
base: 'master'
filters: |
changed:
- 'Dockerfile'
build_ci_docker_image:
runs-on: ubuntu-latest
needs: [check_dockerfile_changed]
if: ${{ needs.check_dockerfile_changed.outputs.changed == 'true' }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Rebuild image
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ghcr.io/blues/note_c_ci:latest
outputs: type=docker,dest=/tmp/note_c_ci_image.tar

- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: note_c_ci_image
path: /tmp/note_c_ci_image.tar

build_docs:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image

- name: Build docs
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/build_docs.sh ghcr.io/blues/note_c_ci:latest
check_libc_dependencies:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image

- name: Check note-c's libc dependencies
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/check_libc_dependencies.sh ghcr.io/blues/note_c_ci:latest
run_unit_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image

- name: Run tests
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_unit_tests.sh ghcr.io/blues/note_c_ci:latest --coverage --mem-check
- name: Adjust lcov source file paths for Coveralls
run: sudo sed -i 's/\/note-c\///g' ./build/test/coverage/lcov.info

- name: Publish test coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/test/coverage/lcov.info

run_low_mem_unit_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image

- name: Run tests with NOTE_LOWMEM defined
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_unit_tests.sh ghcr.io/blues/note_c_ci:latest --mem-check --low-mem --single-precision
run_astyle:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image

- name: Run astyle
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_astyle.sh ghcr.io/blues/note_c_ci:latest
publish_ci_image:
runs-on: ubuntu-latest
# Make sure unit tests unit tests passed before publishing.
needs: [build_ci_docker_image, run_unit_tests]
# Only publish the image if this is a push event and the Docker image was rebuilt
if: ${{ github.event_name == 'push' && needs.build_ci_docker_image.result == 'success' }}

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Push image to registry
uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/blues/note_c_ci:latest
42 changes: 42 additions & 0 deletions src/note-c/.github/workflows/md5srv-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: MD5 Server Tests

on:
workflow_dispatch:
workflow_call: # reusable workflow

jobs:
test-md5srv: # job id
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
TERM: xterm-256color
MD5SRV_TIMEOUT: 5
MD5SRV_DIR: ./test/hitl/scripts
BATS_VERSION: 1.10.0
BATS_LIB_PATH: /usr/lib
# /usr/local/lib on OSX
steps:
- name: Setup Bats and bats libs
uses: brokenpip3/[email protected]
with:
bats-install: true
file-install: false
detik-install: false
- name: Setup BATS_LIB_PATH
run: |
if [ -e /usr/local/lib/bats-support ]; then
echo "BATS_LIB_PATH=/usr/local/lib" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v3
- name: Run Tests
run: |
cd ${{env.MD5SRV_DIR}}
$HOME/.local/bin/bats -p --print-output-on-failure .
- name: Rerun Tests
if: failure()
run: |
cd ${{env.MD5SRV_DIR}}
$HOME/.local/bin/bats -p --print-output-on-failure -x .
Loading

0 comments on commit 9fa88c9

Please sign in to comment.