-
Notifications
You must be signed in to change notification settings - Fork 34
189 lines (168 loc) · 6.9 KB
/
Build_on_Linux.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# Build SEIMS and Doxygen documents on Ubuntu
name: Build on Ubuntu using GCC
on:
push:
branches:
- master
- dev
paths-ignore:
- 'data'
- 'knowledge'
pull_request:
branches:
- dev
paths-ignore:
- 'data'
- 'knowledge'
workflow_dispatch:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
# Container registry domain, and a name for the Docker image that this workflow builds.
IMAGE_NAME: seims
# github container registry
REGISTRY: ghcr.io
NAMESPACE: ${{ github.repository_owner }}
# aliyun ACR
REGION_ID_ACR: cn-hangzhou
REGISTRY_ACR: registry.cn-hangzhou.aliyuncs.com
LOGIN_SERVER: https://registry.cn-hangzhou.aliyuncs.com
NAMESPACE_ACR: ljzhu-geomodels
# dockerfiles and tags
DEBIAN_DOCKERFILE: Dockerfile.TauDEMext
DEBIAN_IMAGE_TAG: ${{ github.ref == 'refs/heads/master' && 'latest' || 'dev-latest' }}
jobs:
build-linux:
# Check GitHub Actions runner images versions: https://github.com/actions/runner-images
runs-on: ubuntu-22.04
services:
mongodb:
image: mongo
ports:
- 27017:27017
steps:
- name: Checkout SEIMS
uses: actions/checkout@v4
- name: Install GDAL, mongo-c-driver, and OpenMPI
run: sudo apt-get update && sudo apt-get install -qq gdal-bin libgdal-dev libmongoc-1.0-0 libmongoc-dev
- name: Setup MSMPI
uses: mpi4py/setup-mpi@v1
with:
mpi: mpich
- name: Checkout SEIMS
uses: actions/checkout@v4
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build and Install SEIMS
# Build your program with the given configuration
run: |
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j 4
cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Build Doc in English
uses: mattnotmitt/doxygen-action@v1.9.2
with:
working-directory: '.'
doxyfile-path: 'doc/Doxyfile.in'
- name: Build Doc in Chinese
uses: mattnotmitt/doxygen-action@v1.9.2
with:
working-directory: '.'
doxyfile-path: 'doc/Doxyfile.zh-cn.in'
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: ${{ github.event.head_commit.message }}
publish_branch: gh-pages
force_orphan: true
publish_dir: ./@CMAKE_CURRENT_BINARY_DIR@/html
# - name: Cache conda
# uses: actions/cache@v4
# env:
# # Increase this value to reset cache if etc/example-environment.yml has not changed
# CACHE_NUMBER: 0
# with:
# path: ~/conda_pkgs_dir
# key:
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('seims/pyseims_env.yml') }}
# - uses: conda-incubator/setup-miniconda@v3
# with:
# activate-environment: pyseims
# environment-file: seims/pyseims_env.yml
# auto-activate-base: false
# auto-update-conda: true
# use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
# - name: Run SEIMS on demo data
# shell: bash -el {0}
# run: |
# #conda info
# #conda list
# #printenv | sort
# cd seims
# python pyseims_check.py
# cd test
# python demo_preprocess.py -name youwuzhen
# python demo_runmodel.py -name youwuzhen
# python demo_postprocess.py -name youwuzhen
# python -m scoop -n 2 demo_parameters_sensitivity.py -name youwuzhen
# python -m scoop -n 2 demo_calibration.py -name youwuzhen
# python -m scoop -n 2 demo_scenario_analysis.py -name youwuzhen
deploy-debian:
needs: build-linux
runs-on: ubuntu-22.04
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
# login alibaba Container Registry
- name: Login to ACR
uses: aliyun/acr-login@v1
with:
login-server: ${{ env.LOGIN_SERVER }}
region-id: ${{ env.REGION_ID_ACR }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# login ghcr.io
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
# https://github.com/marketplace/actions/docker-setup-buildx
- uses: docker/setup-buildx-action@v3
- name: Build based on debian
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ env.DEBIAN_DOCKERFILE }}
push: true
platforms: linux/amd64
provenance: false
tags: |
${{ env.REGISTRY_ACR }}/${{ env.NAMESPACE_ACR }}/${{ env.IMAGE_NAME }}:${{ env.DEBIAN_IMAGE_TAG }}
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.DEBIAN_IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max