Skip to content

Commit

Permalink
refactor CI (#52)
Browse files Browse the repository at this point in the history
* wip

* fix format.yml

* use environment in format.yml

* use setup job

* disable for testing

* empty steps

* wip

* setup not empty

* fix name

* fix uses

* indents

* run format when setup is complete

* fix setup name

* merge remote into refactor-ci

* use selfhosted windows runner

* remove unused

* don't setup python on windows

* dont specify toolset for msvc

* specify x64 build in cmake presets for msvc, don't do it in the ci

* maybe specify it in the ci, too

* don't build debug builds in the ci, use self hosted

* fix typo

* windows volumes

* use local cache on windows

* local cache for buildcache

* fix typo

* use tool cache

* fix local cache paths

* shorten buildcache path

* fix typo

* shorten hashes to save precious filename characters

* split deps caches for presets

* wip
  • Loading branch information
julianharbarth authored Mar 24, 2023
1 parent 8bcbd96 commit 331cd54
Show file tree
Hide file tree
Showing 63 changed files with 699 additions and 871 deletions.
30 changes: 30 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Build SORO-S'
description: 'Builds SORO-S for Linux'

inputs:
preset:
description: 'CMake preset to use'
required: true
runs:
using: 'composite'
steps:
# ==== CMAKE ====
- name: Generate CMake
shell: bash
run: cmake --preset=${{ matrix.config.preset }}

# ==== BUILD ====
- name: Build soro-test
shell: bash
run: |
buildcache -z
cmake --build build/${{ matrix.config.preset }} --target soro-test
buildcache -s
# ==== WEB BUILD ====
- name: Build soro-server
shell: bash
run: |
buildcache -z
cmake --build build/${{ matrix.config.preset }} --target soro-server
buildcache -s
41 changes: 41 additions & 0 deletions .github/actions/create-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: create and upload soro-s artifacts
description: 'creates and uploads soro-s artifacts'

inputs:
preset:
description: 'cmake preset to use'
required: true
artifact:
description: 'name of the artifact to create'
required: true
github_token:
description: 'secrets github token'
required: true

runs:
using: 'composite'
steps:
- name: create artifact
shell: bash
run: |
mkdir -p soro-s
mv build/${{ inputs.preset }}/soro-server soro-s/
mv build/${{ inputs.preset }}/server_resources soro-s/
tar cjf soro-s-${{ inputs.artifact }}.tar.bz2 soro-s
- name: upload artifact
uses: actions/upload-artifact@v1
with:
name: soro-s-${{ inputs.artifact }}
path: soro-s-${{ inputs.artifact }}.tar.bz2

- name: upload artifact as release asset on publish
if: github.event.action == 'published'
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./soro-s-${{ inputs.artifact }}.tar.bz2
asset_name: soro-s-${{ inputs.artifact }}.tar.bz2
asset_content_type: application/x-tar
49 changes: 49 additions & 0 deletions .github/actions/create-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: upload soro-s docker image
description: 'uploads soro-s docker image to github container registry'

inputs:
github_token:
description: 'secrets github token'
required: true

runs:
using: 'composite'
steps:
- name: download artifacts
uses: actions/download-artifact@v3

- name: docker setup-buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: docker login to github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}

- name: docker meta data
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge
- name: docker build and push
uses: docker/build-push-action@v3
with:
push: true
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64

20 changes: 20 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: soro-s tests
description: execute soro-s tests

runs:
using: 'composite'

steps:
- name: run soro-s tests
shell: bash
run: |
cd ./build/${{ matrix.config.preset }}
./soro-test
cd ../../
- name: run soro-server in test mode
shell: bash
run: |
cd ./build/${{ matrix.config.preset }}
./soro-server -t
cd ../../
26 changes: 17 additions & 9 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
name: Check Format
name: check format

on:
push:
branches: [ master, advance-simulation ]
branches: [ master ]
pull_request:
branches: [ master, advance-simulation ]
branches: [ master ]
release:
types:
- published

jobs:
formatting:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install clang-format-15
- name: install jq
run: |
sudo apt install jq
- name: set CLANG_FORMAT_COMMAND
run: | # extract the clang format command from the CMakePresets.json
CLANG_FORMAT_COMMAND=$(jq -r '.configurePresets[] | select(.name == "clang-preset") | .cacheVariables.CMAKE_C_COMPILER' CMakePresets.json)
- name: install clang-format
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt-get install -y --no-install-recommends clang-format-15
sudo apt install -y --no-install-recommends $CLANG_FORMAT_COMMAND
- name: Format files
run: find include src test tools web/iss-server -type f -a \( -name "*.cc" -o -name "*.h" \) -print0 | xargs -0 clang-format-15 -i
- name: format files
run: find -name "*.cc" -o -name "*.h" -print0 | xargs -0 $CLANG_FORMAT_COMMAND -i

- name: Check for differences
run: |
Expand Down
Loading

0 comments on commit 331cd54

Please sign in to comment.