-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'task/#21677-add-github-actions' into 'integration'
Task #21677 - Add GitHub Actions See merge request elektrobit/base-os/safu!20
- Loading branch information
Showing
5 changed files
with
202 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
# CI with GitHub Actions | ||
|
||
## Intentions in using GitHub Actions | ||
|
||
We want to test all PRs before mergeing by: | ||
- [x] build test | ||
- [ ] code linting | ||
- [ ] license check | ||
- [x] unit-tests | ||
- [ ] creating a test coverage report | ||
- [ ] smoke tests | ||
- [ ] integration tests | ||
- [ ] running benchmarks | ||
- [ ] automatic upload of new releases | ||
|
||
## How to develop GitHub Actions | ||
|
||
Find a detailed documentation [here](https://docs.github.com/de/actions) | ||
|
||
### Adding Badges with CI status | ||
|
||
Paste a link in the form of `![badge](https://github.com/Elektrobit/safu/actions/workflows/build-and-test.yml/badge.svg)` where you want to integrate the badge for the `build-and-test` workflow. | ||
|
||
Find an explanation [here](https://docs.github.com/de/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge) | ||
|
||
### Running GitHub Actions locally | ||
|
||
To run the GitHub Actions locally [act](https://github.com/nektos/act) can be used. | ||
|
||
The way the Actions are written right now they need an ubuntu image with passwordless sudo. | ||
With that image build under the tag `ubuntu-sudo` the command can be run: | ||
|
||
```bash | ||
act -P ubuntu-latest=ubuntu-sudo --pull=false --artifact-server-path=/tmp/artifacts | ||
``` | ||
which leaves the build artefacts under `/tmp/artifacts` | ||
|
||
|
||
### known issues | ||
|
||
- job artefacts lose their permissions so executables are no longer set as executable when downloaded in a different job | ||
- a possibility to fix that ist to run `chmod` on all files needing specific permissions. | ||
for example to make all utests in the Release build folder executable: | ||
```bash | ||
for test in $(find build/Release/cmake/ -name "*_utest"); do | ||
chmod +x $test | ||
done | ||
``` | ||
- uploading and downloading artefacts with `actions/upload-artifact` & `actions/download-artifact` takes a very long time, especially with artefacts containing a lot of (small) files. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
name: Build and Test | ||
on: [ push, workflow_dispatch, pull_request ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
build_type: [Debug, Release] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Build Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y \ | ||
build-essential \ | ||
cmake \ | ||
curl \ | ||
git \ | ||
libcmocka-dev \ | ||
libcurl4-openssl-dev \ | ||
libesmtp-dev \ | ||
libjson-c-dev \ | ||
liblog4c-dev \ | ||
libmnl-dev \ | ||
libsqlite3-0 \ | ||
libsqlite3-dev \ | ||
libssl-dev \ | ||
ninja-build \ | ||
pkg-config \ | ||
python-is-python3 \ | ||
python3-pip \ | ||
python3-venv \ | ||
sqlite3 | ||
- name: checkout and build dependecies | ||
run: ci/install_deps.py -G | ||
- name: Build ${{ matrix.build_type }} | ||
env: | ||
DESTDIR: ${{ github.workspace }}/build/${{ matrix.build_type }}/dist | ||
run: | | ||
cmake -B ./build/${{ matrix.build_type }}/cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
make -C ./build/${{ matrix.build_type }}/cmake all install | ||
- name: save build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.build_type }}-build | ||
path: build/${{ matrix.build_type}}/dist | ||
- name: run unit tests (${{ matrix.build_type }}) | ||
run: ci/run_utest.sh ${{ matrix.build_type }} | ||
- name: save ${{ matrix.build_type }} unit test report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: ${{ matrix.build_type }}-test-report | ||
path: build/${{ matrix.build_type }}/result/unit_test/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
name: Build Documentation | ||
on: [ push, workflow_dispatch, pull_request ] | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
documentation: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Build Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y \ | ||
curl \ | ||
expat \ | ||
git \ | ||
locales \ | ||
net-tools \ | ||
netcat \ | ||
nodejs \ | ||
pandoc \ | ||
plantuml \ | ||
python-is-python3 \ | ||
python3-pip \ | ||
python3-venv \ | ||
wget \ | ||
- name: setup python Virtual env | ||
run: | | ||
python -m venv ${{ github.workspace }}/.venv | ||
. ${{ github.workspace }}/.venv/bin/activate | ||
python -m pip install \ | ||
beautifulsoup4==4.12.2 \ | ||
clang==16.0.1.1 \ | ||
sphinx==7.2.6 \ | ||
sphinx-c-autodoc==1.3.0 \ | ||
sphinx-copybutton==0.5.2 \ | ||
sphinx-favicon==1.0.1 \ | ||
sphinxcontrib-programoutput==0.17 | ||
- name: install libcland 16 for sphinx c autodoc | ||
# needet as long as libclang 16 isn't packaged in ubuntu-latest | ||
run: | | ||
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | ||
echo "" | sudo tee -a /etc/apt/sources.list | ||
echo "# for llvm 16 packages" | sudo tee -a /etc/apt/sources.list | ||
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" | sudo tee -a /etc/apt/sources.list | ||
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" | sudo tee -a /etc/apt/sources.list | ||
cat /etc/apt/sources.list | ||
sudo apt-get update | ||
sudo apt-get install -y libclang1-16 | ||
sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-16.so.1 /usr/lib/libclang-16.so | ||
- name: Build Documentation | ||
run: ci/build_doc.sh | ||
env: | ||
SPHINX_VENV: "${{ github.workspace }}/.venv" | ||
- name: pack documentation for GitHub pages | ||
run: | | ||
tar \ | ||
--dereference --hard-dereference \ | ||
--directory "${{ github.workspace }}/build/doc/" \ | ||
-cvf "$RUNNER_TEMP/artifact.tar" \ | ||
. | ||
- name: save documentation | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: github-pages | ||
path: ${{ runner.temp }}/artifact.tar | ||
if-no-files-found: error | ||
|
||
publish-gh-pages: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref_name == 'main' }} | ||
needs: documentation | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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
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