-
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.
doc: add .sparrow-example-ci.yml example
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 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,65 @@ | ||
# if you use github, you should move this file to .github/workflows | ||
name: github-ci | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- test | ||
|
||
jobs: | ||
CIManager: | ||
runs-on: ubuntu-latest | ||
env: | ||
# ========================= CI ========================= | ||
# [stage] = pre | ||
CI_STAGE_PRE_JOB_PRE_CHECK_SWITCH: "ON" | ||
CI_STAGE_PRE_JOB_PRE_CHECK_CMD: "docker-compose --version" | ||
CI_STAGE_PRE_JOB_PRE_INSTALL_SWITCH: "ON" | ||
CI_STAGE_PRE_JOB_PRE_INSTALL_CMD: | | ||
cd sparrow && bash _install.sh && bash ./sparrow startone go && cd .. | ||
mkdir -p ./sparrow/go/data/mapserver | ||
rsync -av --exclude='../mapserver/sparrow/' ../mapserver/ "./sparrow/go/data/mapserver" | ||
ls ./sparrow/go/data | ||
# [stage] = test | ||
CI_STAGE_TEST_JOB_UNIT_TEST_SWITCH: "ON" | ||
CI_STAGE_TEST_JOB_UNIT_TEST_CMD: "cd pkg/util && go test -v ." | ||
CI_STAGE_TEST_JOB_CHECK_CODE_SWITCH: "ON" | ||
CI_STAGE_TEST_JOB_CHECK_CODE_CMD: "" | ||
# [stage] = build | ||
CI_STAGE_BUILD_JOB_LOCAL_BUILD_SWITCH: "ON" | ||
CI_STAGE_BUILD_JOB_LOCAL_BUILD_CMD: | | ||
env="test" | ||
docker exec -it sparrow_container_${env}_go bash -c "cd /var/data/go/mapserver && go mod tidy && nohup go run mapserver.go -f etc/application.${env}.yaml &" | ||
CI_STAGE_BUILD_JOB_APIDOC_GEN_SWITCH: "ON" | ||
CI_STAGE_BUILD_JOB_APIDOC_GEN_CMD: "" | ||
# ========================= CD ========================= | ||
# [stage] = deploy | ||
CD_STAGE_DEPLOY_JOB_SSH_SWITCH: "ON" | ||
CD_STAGE_DEPLOY_JOB_SSH_CMD: "" | ||
# [stage] = monitor | ||
CD_STAGE_MONITOR_JOB_API_TEST_SWITCH: "ON" | ||
CD_STAGE_MONITOR_JOB_API_TEST_CMD: "" | ||
CD_STAGE_MONITOR_JOB_HEALTH_CHECK_SWITCH: "ON" | ||
CD_STAGE_MONITOR_JOB_HEALTH_CHECK_CMD: "" | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: | | ||
printf "================ Start to Boot CIManager ================\n" | ||
git clone https://github.com/wgrape/CIManager.git | ||
cp -an ./CIManager/.pipeline ./ | ||
rm -rf ./CIManager | ||
cd .pipeline | ||
printf "================ End Boot ================\n\n" | ||
printf "================ Debug Start ================\n\n" | ||
show_env(){ | ||
echo "1. cat /proc/version="$(cat /proc/version) | ||
echo "2. pwd="$(pwd) | ||
echo "3. ls="$(ls -a) | ||
} | ||
show_env | ||
printf "================ End Debug ================\n\n" | ||
printf "\e[36m>>>>>>>>>>> Start Pipeline\e[0m\n\n" | ||
# you can run sudo with the -E/--preserve-env switch, sudo -E/--preserve-env ..., which retains environment variables. | ||
sudo --preserve-env bash start.sh | ||
printf "\e[36m<<<<<<<<<<< End Pipeline\e[0m" |