-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (101 loc) · 3.29 KB
/
ci_cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# check spelling, codestyle
name: GitHub CI
# run only on main branch. This avoids duplicated actions on PRs
on:
pull_request:
push:
tags:
- "*"
branches:
- main
workflow_dispatch:
inputs:
jobs:
style:
name: Pre-commit Check
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.FILETRANSFER_SERVER_TOKEN }}
- name: Build and run pre-commit hooks via docker
run: |
docker build -f docker/Dockerfile --target precommit --tag filetransfer-precommit .
docker run filetransfer-precommit
env:
DOCKER_BUILDKIT: '1'
build:
name: Compile and Test
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
conan_config: linux_x86_64_Release
- os: windows-2019
conan_config: windows_x86_64_Release
steps:
- uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.FILETRANSFER_SERVER_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/cache@v3
name: Pip cache
with:
path: ${{ startsWith(runner.os, 'Linux') && '~/.cache/pip' || '~\AppData\Local\pip\Cache' }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements_dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dev dependencies
run: |
pip install -U pip wheel
pip install -r requirements_dev.txt
- name: Run Conan and build with CMake
run: |
conan install -of build --build missing --profile:host=./conan/${{ matrix.conan_config }} --profile:build=./conan/${{ matrix.conan_config }} ./conan
cmake -B build . -DCMAKE_TOOLCHAIN_FILE='build/conan_toolchain.cmake' -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
# - name: Test
# run: |
# ./build/bin/server
docker-build:
name: Build and publish Docker container
needs: [style, build] # run only for successful build
runs-on: ubuntu-22.04
env:
REGISTRY: ghcr.io
IMAGE_OWNER: ansys-internal
IMAGE_NAME_BASE: tools-filetransfer
steps:
- uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.FILETRANSFER_SERVER_TOKEN }}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set the current date as build date
run: |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Build image and export to GHCR
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
target: app_minimal
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME_BASE }}:latest
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
VCS_REF=${{ github.sha }}