Diff

Differences From Artifact [1d1fbb422c]:

To Artifact [d01b60e48f]:


43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
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=''







|
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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=()
includedBranches=('')
buildCommands=('./autogen.sh || :' ./configure make)
testCommands=()
releaseCommands=()
builderID=''
projectName="$(fossil info -R "${repository}" | awk '/^project-name:/{ sub(/^project-name: */, ""); gsub(/ /, ""); print; }')"
tagSuffix=''
tagPrefix=''
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
## 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
			;;
	esac


	## 6.b. Find the branch working directory
	branchdir="$(echo "${branch}" | sed 's@[^A-Za-z0-9-]@_@g')"
	builddir="${workdir}/build-output/branch-${branchdir}"
	branchdir="${workdir}/working-copies/branch-${branchdir}"
	mkdir -p "${branchdir}"

	## 6.c. Determine current checkout ID
	checkout="$(fossil info -R "${repository}" "${branch}" | awk '/^uuid:/{ print $3 "T" $4 "-" $2 }')"
	builddir="${builddir}/checkout-${checkout}"

	## 6.d. Determine if build even needs to occur
	if [ -d "${builddir}" ]; then
		continue
	fi
	mkdir -p "${builddir}"

	## 6.e. Check-out or update the branch
	(
		cd "${branchdir}" || exit 1

		if [ ! -f '.fslckout' ]; then
			fossil open "${repository}" "${branch}" --nested
		else
			fossil update "${branch}"
		fi
	) > "${builddir}/update.log" 2>&1 || continue

	## 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







>
>
>
>
>
|

>
>
>
>
>
|
>
>
>
|
|
>
>
>
>
>
>
>
>
|
<
<
>

|





|



|





|










|









|











|




















|


|



|

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
188
## 5.d. Post-process config
if [ -z "${tagSuffix}" ]; then
	if [ -n "${builderID}" ]; then
		tagSuffix="-${builderID}"
	fi
fi

# 6. Perform any configured initialization
for cmd in "${initCommands[@]}"; do
	eval "${cmd}" >/dev/null 2>/dev/null || :
done

# 7. For each branch, attempt to build
for branch in "${branches[@]}"; do
	## 7.a. Only process specific branches
	ignoreBranch='1'
	for testBranch in "${includedBranches[@]}"; do
		if echo "${branch}" | grep "${testBranch}" >/dev/null; then
			ignoreBranch='0'

			break
		fi
	done

	for testBranch in "${excludedBranches[@]}"; do
		if echo "${branch}" | grep "${testBranch}" >/dev/null; then
			ignoreBranch='1'

			break
		fi
	done

	if [ "${ignoreBranch}" = '1' ]; then
		continue


	fi

	## 7.b. Find the branch working directory
	branchdir="$(echo "${branch}" | sed 's@[^A-Za-z0-9-]@_@g')"
	builddir="${workdir}/build-output/branch-${branchdir}"
	branchdir="${workdir}/working-copies/branch-${branchdir}"
	mkdir -p "${branchdir}"

	## 7.c. Determine current checkout ID
	checkout="$(fossil info -R "${repository}" "${branch}" | awk '/^uuid:/{ print $3 "T" $4 "-" $2 }')"
	builddir="${builddir}/checkout-${checkout}"

	## 7.d. Determine if build even needs to occur
	if [ -d "${builddir}" ]; then
		continue
	fi
	mkdir -p "${builddir}"

	## 7.e. Check-out or update the branch
	(
		cd "${branchdir}" || exit 1

		if [ ! -f '.fslckout' ]; then
			fossil open "${repository}" "${branch}" --nested
		else
			fossil update "${branch}"
		fi
	) > "${builddir}/update.log" 2>&1 || continue

	## 7.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'

	### 7.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

	### 7.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

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

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

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