Check-in [90ddcf0e78]
Overview
Comment:Added tagging support and fixed a few bugs
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 90ddcf0e78b195fc564f4733dfde5dc2830d02f0c1890709a6b1668bc55372fb
User & Date: rkeene on 2017-10-23 16:03:54.994
Other Links: manifest | tags
Context
2017-10-23
21:43
Add better support for excluding and including branches and initialization commands check-in: 43857910ad user: rkeene tags: trunk
16:03
Added tagging support and fixed a few bugs check-in: 90ddcf0e78 user: rkeene tags: trunk
15:41
Started autobuild script which will build and test Fossil projects check-in: 9ee3ee13b7 user: rkeene tags: trunk
Changes
9
10
11
12
13
14
15




16
17
18
19
20
21
22
	exit 1
fi

if [ -z "${fossilCIDir}" ]; then
	fossilCIDir='.fossil-ci'
fi





# 1. Register cleanup
tmpdir=''
function cleanup() {
	if [ -n "${tmpdir}" ]; then
		rm -rf "${tmpdir}"
	fi
}







>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
	exit 1
fi

if [ -z "${fossilCIDir}" ]; then
	fossilCIDir='.fossil-ci'
fi

# 0. Resolve paths
repository="$(cd "$(dirname "${repository}")" && echo "$(pwd)/$(basename "${repository}")")" || exit 1
workdir="$(mkdir -p "${workdir}" && cd "${workdir}" && pwd)" || exit 1

# 1. Register cleanup
tmpdir=''
function cleanup() {
	if [ -n "${tmpdir}" ]; then
		rm -rf "${tmpdir}"
	fi
}
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
## 2.c. Basic locale
unset $(locale | cut -f 1 -d =)

## 2.d. Sane umask
umask 022

# 3. Update the Fossil repository
fossil pull -R "${repository}" || :

# 4. Get a list of branches
branches=( $(fossil branch -R "${repository}" list) )

# 5. Get Fossil CI configuration from the trunk branch
## 5.a. Set default config
excludedBranches=''
buildCommands=('./autogen.sh || :' ./configure make)


builderID=''
projectName="$(fossil info -R "${repository}" | awk '/^project-name:/{ sub(/^project-name: */, ""); gsub(/ /, ""); print; }')"



## 5.b. Read config
config="$(fossil cat -R "${repository}" -r trunk "${fossilCIDir}/config")" || :

## 5.c Load config
if [ -f  ~/.fossil-ci/config ]; then
	. ~/.fossil-ci/config
fi

eval "${config}"

if [ -f ~/.fossil-ci/"${projectName}"/config ]; then
	. ~/.fossil-ci/"${projectName}"/config
fi








# 6. For each branch, attempt to build
for branch in "${branches[@]}"; do
	## 6.a. Ignore excluded branches
	case "${branch}" in
		${excludedBranches})
			continue







|








>
>


>
>


|











>
>
>
>
>
>
>







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
## 2.c. Basic locale
unset $(locale | cut -f 1 -d =)

## 2.d. Sane umask
umask 022

# 3. Update the Fossil repository
fossil sync -R "${repository}" >/dev/null 2>/dev/null || :

# 4. Get a list of branches
branches=( $(fossil branch -R "${repository}" list) )

# 5. Get Fossil CI configuration from the trunk branch
## 5.a. Set default config
excludedBranches=''
buildCommands=('./autogen.sh || :' ./configure make)
testCommands=()
releaseCommands=()
builderID=''
projectName="$(fossil info -R "${repository}" | awk '/^project-name:/{ sub(/^project-name: */, ""); gsub(/ /, ""); print; }')"
tagSuffix=''
tagPrefix=''

## 5.b. Read config
config="$(fossil cat -R "${repository}" -r trunk "${fossilCIDir}/config" 2>/dev/null)" || :

## 5.c Load config
if [ -f  ~/.fossil-ci/config ]; then
	. ~/.fossil-ci/config
fi

eval "${config}"

if [ -f ~/.fossil-ci/"${projectName}"/config ]; then
	. ~/.fossil-ci/"${projectName}"/config
fi

## 5.d. Post-process config
if [ -z "${tagSuffix}" ]; then
	if [ -n "${builderID}" ]; then
		tagSuffix="-${builderID}"
	fi
fi

# 6. For each branch, attempt to build
for branch in "${branches[@]}"; do
	## 6.a. Ignore excluded branches
	case "${branch}" in
		${excludedBranches})
			continue
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


	## 6.f. Build and log the results, if there are any
	build_pass='1'
	(
		cd "${branchdir}" || exit 1

		for cmd in "${buildCommands[@]}"; do
			eval "set -x; ${cmd}" || exit 1
		done
	) > "${builddir}/build.log" 2>&1 || build_pass='0'

	### 6.g. Test the branch
	tests_pass='-1'
	if [ "${build_pass}" = '1' ]; then
		tests_pass='1'
		(
			cd "${branchdir}" || exit 1

			for cmd in "${testCommands[@]}"; do
				eval "set -x; ${cmd}" || exit 1
			done
		) > "${builddir}/test.log" 2>&1 || tests_pass='0'
	fi

	### 6.h. Tag the branch




















	### 6.i. Upload the logs somewhere if requested


	### 6.j. Upload build artifacts somewhere if requested

done

# 7. Clean up any branches that no longer exist








|




<






|




|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>

>



>
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

	## 6.f. Build and log the results, if there are any
	build_pass='1'
	(
		cd "${branchdir}" || exit 1

		for cmd in "${buildCommands[@]}"; do
			( eval "set -x; ${cmd}" ) || exit 1
		done
	) > "${builddir}/build.log" 2>&1 || build_pass='0'

	### 6.g. Test the branch

	if [ "${build_pass}" = '1' ]; then
		tests_pass='1'
		(
			cd "${branchdir}" || exit 1

			for cmd in "${testCommands[@]}"; do
				( eval "set -x; ${cmd}" ) || exit 1
			done
		) > "${builddir}/test.log" 2>&1 || tests_pass='0'
	fi

	### 6.h. Tag the branch with
	tagsToAdd=()
	if [ "${build_pass}" = '1' ]; then
		tagsToAdd=("${tagsToAdd[@]}" build-pass)

		if [ "${tests_pass}" = '1' ]; then
			tagsToAdd=("${tagsToAdd[@]}" tests-pass)
		else
			tagsToAdd=("${tagsToAdd[@]}" tests-fail)
		fi
	else
		tagsToAdd=("${tagsToAdd[@]}" build-fail)
	fi

	tagsToAddOpts=()
	for tag in "${tagsToAdd[@]}"; do
		tagsToAddOpts=("${tagsToAddOpts[@]}" --tag "${tagPrefix}${tag}${tagSuffix}")
	done

	fossil amend -R "${repository}" "${branch}" "${tagsToAddOpts[@]}" > "${builddir}/update.log" 2>&1

	### 6.i. Upload the logs somewhere if requested
	#### XXX:TODO

	### 6.j. Upload build artifacts somewhere if requested
	#### XXX:TODO
done

# 7. Clean up any branches that no longer exist
## XXX:TODO