Skip to content

Commit edc9e16

Browse files
committed
feature: add gitlab ci yml and a documentation stage
also fix the hugo build
1 parent 06acc3d commit edc9e16

File tree

8 files changed

+212
-32
lines changed

8 files changed

+212
-32
lines changed

Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ RUN chmod -R 755 /tmp/mpi &&\
2222
/tmp/mpi/install.sh "/usr/local" &&\
2323
rm -rf /tmp/mpi &&\
2424
# Configuration
25-
envcli config set cache-path "/cache"
25+
mkdir -p /cache &&\
26+
envcli config set cache-path "/cache" &&\
27+
# Aliases
28+
envcli install-aliases &&\
29+
# Permissions
30+
chmod +x /usr/local/bin/*
2631

2732
############################################################
2833
# Execution

src/libexec/mpi/actions/action-hugo-build.bash

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@ set -euo pipefail
33

44
# Main Function
55
#
6-
# Environment:
7-
# HUGO_SOURCE: source directory used to generate hugo sites
8-
#
96
# Returns the exit code of the last command executed or 0 otherwise.
107
function main()
118
{
129
# configuration
1310
HUGO_SOURCE=${HUGO_SOURCE:-.}
14-
HUGO_URL=${HUGO_URL:-http://localhost}
11+
HUGO_TARGET=${HUGO_TARGET:-${ARTIFACT_DIR}/hugo}
12+
HUGO_URL=${HUGO_URL:-/}
1513

1614
# get dependencies
17-
if test -f config.toml; then
18-
@mpi.container_command hugo --source "$HUGO_SOURCE" --destination "$ARTIFACT_DIR" --minify --gc --baseURL "$HUGO_URL"
15+
if test -f "${HUGO_SOURCE}/config.toml"; then
16+
@mpi.log_message "INFO" "Generating hugo documentation from [${HUGO_SOURCE}], target [${HUGO_TARGET}]!"
17+
@mpi.container_command hugo --source "${HUGO_SOURCE}" --minify --gc --baseUrl "/" --log --verboseLog
18+
19+
rm -rf "${HUGO_TARGET}"
20+
cp -R "${HUGO_SOURCE}/public" "${HUGO_TARGET}"
21+
rm -rf "${HUGO_SOURCE}/public"
1922
else
2023
@mpi.log_message "ERROR" "Hugo needs a config.toml!"
2124
exit 1
25+
fi
2226
}
2327

2428
# entrypoint
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Main Function
5+
#
6+
# Returns the exit code of the last command executed or 0 otherwise.
7+
function main()
8+
{
9+
# configuration
10+
HUGO_SOURCE=${HUGO_SOURCE:-.}
11+
12+
# get dependencies
13+
if test -f "${HUGO_SOURCE}/config.toml"; then
14+
@mpi.log_message "INFO" "Generating hugo documentation from [${HUGO_SOURCE}] and watching directory for changes!"
15+
@mpi.container_command --port 1313:1313 hugo server --source "${HUGO_SOURCE}" --minify --gc --log --verboseLog --baseUrl "/" --watch
16+
else
17+
@mpi.log_message "ERROR" "Hugo needs a config.toml!"
18+
exit 1
19+
fi
20+
}
21+
22+
# entrypoint
23+
main "$@"

src/libexec/mpi/cfg/.envcli.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ images:
7373
provides:
7474
- hugo
7575
- htmlproofer
76-
image: docker.io/cibuilds/hugo:0.58.2
76+
image: docker.io/cibuilds/hugo:0.71
7777
# Infrastructure
7878
# - Kubernetes
7979
- name: KubeCTL

src/libexec/mpi/common/logging.bash

+1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030

3131
# log the message
3232
>&2 echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${log_priority} : ${log_message}"
33+
3334
return 0
3435
}

src/libexec/mpi/stages/stage-documentation.bash

+23-8
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,35 @@ set -euo pipefail
33

44
# Main Function
55
#
6-
# Environment:
7-
# none
8-
#
96
# Returns the exit code of the last command executed or 0 otherwise.
107
function main()
118
{
12-
# hugo
13-
if [[ ${DOCUMENTATION_TYPE} =~ ^hugo$ ]]; then
9+
# kind: documentation
10+
documentationType="${DOCUMENTATION_TYPE:-none}"
11+
# - hugo
12+
if [ "${documentationType}" == "hugo" ]; then
1413
@mpi action hugo-build
15-
exit 0
14+
# - default
15+
else
16+
@mpi.log_message "INFO" "not generating a documentation, type [${documentationType}] is not supported!"
1617
fi
1718

18-
# no match
19-
@mpi.log_message "WARN" "project type ${DOCUMENTATION_TYPE} is not supported!"
19+
# kind: changelog
20+
# - release notes
21+
if [ "$NCI_COMMIT_REF_TYPE" == "tag" ]; then
22+
# generate changelog
23+
@mpi action changelog-generate --ref="$NCI_COMMIT_REF_NAME" --output="${TMP_DIR}/changelog"
24+
25+
# notification
26+
# - discord
27+
if [ -n "$RELEASE_WEBHOOK_DISCORD" ]; then
28+
@mpi.discord.send_webhook "RELEASE_WEBHOOK_DISCORD" "Releasebot" "$(<${TMP_DIR}/changelog)"
29+
fi
30+
# - rocketchat
31+
if [ -n "$RELEASE_WEBHOOK_ROCKETCHAT" ]; then
32+
@mpi.rocketchat.send_webhook "RELEASE_WEBHOOK_ROCKETCHAT" "Releasebot" "$(<${TMP_DIR}/changelog)"
33+
fi
34+
fi
2035
}
2136

2237
# entrypoint

src/libexec/mpi/stages/stage-publish.bash

-16
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ function main()
5454
@mpi.log_message "WARN" "publishType GitHub is not supported yet!"
5555
return 0
5656
fi
57-
58-
# release notes
59-
if [ "$NCI_COMMIT_REF_TYPE" == "tag" ]; then
60-
# generate changelog
61-
@mpi action changelog-generate --ref="$NCI_COMMIT_REF_NAME" --output="${TMP_DIR}/changelog"
62-
63-
# notification
64-
# - discord
65-
if [ -n "$PUBLISH_WEBHOOK_DISCORD" ]; then
66-
@mpi.discord.send_webhook "PUBLISH_WEBHOOK_DISCORD" "Releasebot" "$(<${TMP_DIR}/changelog)"
67-
fi
68-
# - rocketchat
69-
if [ -n "$PUBLISH_WEBHOOK_ROCKETCHAT" ]; then
70-
@mpi.rocketchat.send_webhook "PUBLISH_WEBHOOK_ROCKETCHAT" "Releasebot" "$(<${TMP_DIR}/changelog)"
71-
fi
72-
fi
7357
}
7458

7559
# entrypoint
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
##
2+
# Modular Pipeline CI Configuration
3+
##
4+
5+
# Variables
6+
variables:
7+
# cluster
8+
DOCKER_DRIVER: "${DOCKER_DRIVER:-overlay2}"
9+
# git settings
10+
GIT_STRATEGY: clone
11+
GIT_DEPTH: 10
12+
# submodule support
13+
GIT_SUBMODULE_STRATEGY: recursive
14+
# gitlab pages
15+
HUGO_URL: "${HUGO_URL:-https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME}/}"
16+
17+
# Services
18+
services:
19+
- name: docker:19.03.9-dind
20+
21+
# Cache
22+
cache: &project-cache
23+
key: "$CI_PROJECT_ID"
24+
paths:
25+
- /cache/gradle/wrapper
26+
27+
# Stages
28+
stages:
29+
- build
30+
- test
31+
- package
32+
- audit
33+
- publish
34+
- documentation
35+
- cleanup
36+
37+
# Stage Template
38+
.stage-template: &stage-template
39+
image: docker.io/envcli/modular-pipeline:latest
40+
artifacts:
41+
paths:
42+
- dist
43+
- tmp
44+
expire_in: 1 hour
45+
46+
# Stage - Build
47+
Build:
48+
<<: *stage-template
49+
stage: build
50+
cache:
51+
<<: *project-cache
52+
policy: pull-push
53+
script:
54+
- mpi stage build
55+
only:
56+
refs:
57+
- branches
58+
- tags
59+
except:
60+
variables:
61+
- $DISABLE_BUILD
62+
63+
# Stage - Test
64+
Test:
65+
<<: *stage-template
66+
stage: test
67+
cache:
68+
<<: *project-cache
69+
policy: pull-push
70+
script:
71+
- mpi stage test
72+
only:
73+
refs:
74+
- branches
75+
- tags
76+
except:
77+
variables:
78+
- $DISABLE_TEST
79+
80+
# Stage - Package
81+
Package:
82+
<<: *stage-template
83+
stage: package
84+
script:
85+
- mpi stage package
86+
only:
87+
refs:
88+
- branches
89+
- tags
90+
except:
91+
variables:
92+
- $DISABLE_PACKAGE
93+
94+
# Stage - Audit
95+
Audit:
96+
<<: *stage-template
97+
stage: audit
98+
script:
99+
- mpi stage audit
100+
only:
101+
refs:
102+
- branches
103+
- tags
104+
except:
105+
variables:
106+
- $DISABLE_AUDIT
107+
108+
# Stage - Publish
109+
Publish:
110+
<<: *stage-template
111+
stage: publish
112+
script:
113+
- mpi stage publish
114+
only:
115+
refs:
116+
- branches
117+
- tags
118+
except:
119+
variables:
120+
- $DISABLE_PUBLISH
121+
122+
# Stage - Documentation
123+
Documentation:
124+
<<: *stage-template
125+
stage: documentation
126+
script:
127+
- mpi stage documentation
128+
only:
129+
refs:
130+
- branches
131+
- tags
132+
except:
133+
variables:
134+
- $DISABLE_DOCUMENTATION
135+
136+
# Stage - Performance
137+
CleanUp:
138+
<<: *stage-template
139+
stage: cleanup
140+
script:
141+
- mpi stage cleanup
142+
only:
143+
refs:
144+
- branches
145+
- tags
146+
except:
147+
variables:
148+
- $DISABLE_CLEANUP

0 commit comments

Comments
 (0)