This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add .cirrus.yml for FreeBSD (amd64, i386) CI/CD #2911
Draft
saper
wants to merge
22
commits into
sass:master
Choose a base branch
from
saper:test-cirrus-ci
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
43e078b
Add .cirrus.yml for FreeBSD (amd64, i386) CI/CD
am11 cf5f477
Use scraping to get latest version of node/npm
am11 eb5801f
Switch to Sass org account
am11 fb33306
Use last version of mocha that supports node 0.x
am11 4f6b9d8
Use cbsd v12.0.4 from ports
am11 0aa9518
Remove obsolete comment
am11 a453c23
Merge branch 'cirrus-ci' into test-cirrus-ci
saper a328823
april 2020 update
saper d0ef32f
more verbose about our config
saper b81e2bb
Use fresh repository definition
saper 94f170c
Use local latest FreeBSD repository
saper b0a351c
We need local REPOS_DIR outside of the jail
saper 4f30a92
build one node for now
saper 9a77aa0
typo
saper 2391527
need git to checkout sass-spec
saper 514ba32
Use git-lite to install faster (we don't need perl)
saper 955d4f2
Print out artifacts
saper 9f3d09b
Do not try to fetch the binary
saper eddd3d4
/tmp/scripts2939487f6999eb9d18a44784045d87f3.sh: 7: Syntax error: Unt…
saper 95859f5
Do not download node header files
saper 500548f
<uv.h> is not bundled with node with FreeBSD ports
saper 390b08f
Expand matrix to node 12 and 13
saper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,78 @@ | ||
freebsd_instance: | ||
image_family: freebsd-11-3-snap | ||
|
||
freebsd_build_task: | ||
|
||
# | ||
# We support only node versions available in the FreeBSD ports tree | ||
# Currently supported node versions can be figured out as follows: | ||
# | ||
# Check the node versions supported by the npm port: | ||
# https://svnweb.freebsd.org/ports/head/www/npm/Makefile?view=markup | ||
# | ||
# www/npm port contains options to build with different node engines | ||
# in the form of | ||
# xxx_RUN_DEPENDS= node>0.8:pppppp | ||
# "ppppp" above is the port name, for example www/node12 | ||
# | ||
# "www/node" port is the latest and its is a moving target | ||
# You have to check its Makefile to figure out which version it represents: | ||
# https://svnweb.freebsd.org/ports/head/www/node/Makefile?view=markup | ||
# | ||
# Typically this means once www/node gets promoted from node 19 to 20 | ||
# "- package: npm-node19" needs to be added before the "package: npm" | ||
# line. | ||
# | ||
env: | ||
matrix: | ||
- package: npm-node10 | ||
- package: npm-node12 | ||
- package: npm | ||
|
||
env: | ||
matrix: | ||
- abi: freebsd:11:x86:64 | ||
REPOS_DIR: .cirrus/pkg/repos | ||
- abi: freebsd:11:x86:32 | ||
jail_name: j11i386 | ||
exec_prefix: cbsd jexec jname=j11i386 | ||
working_dir: /etc/skel | ||
REPOS_DIR: /etc/skel/.cirrus/pkg/repos | ||
|
||
env: | ||
GH_API_TOKEN: ENCRYPTED[5e482f417304528148bb96eca8d030eacd6ab9972d482485fc4d42907283b995f658b351e0676e9493a37d815398f541] | ||
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: yes | ||
CPPFLAGS: -I/usr/local/include | ||
|
||
prepare_script: | ||
- pkg -R .cirrus/pkg/repos update -f; | ||
- | | ||
if test "$abi" = "freebsd:11:x86:32"; then | ||
pkg -R .cirrus/pkg/repos install -y cbsd | ||
./scripts/configure_freebsd_ci_jail.sh $jail_name $CIRRUS_WORKING_DIR; | ||
$exec_prefix pkg update -f | ||
fi | ||
- $exec_prefix pkg install -y "${package}" python2 git-lite | ||
- $exec_prefix node --version | ||
- $exec_prefix npm --version | ||
- $exec_prefix clang++ --version | ||
|
||
build_script: | ||
- | | ||
if [ -n "${working_dir}" ]; then change_dir="cd ${working_dir} &&"; fi | ||
echo "$change_dir npm install --unsafe-perm --production --nodedir=/usr/local" | $exec_prefix /bin/sh | ||
echo "Generated files:" | ||
echo "$change_dir find vendor" | $exec_prefix /bin/sh | ||
|
||
publish_task: | ||
only_if: $CIRRUS_TAG != "" | ||
script: | ||
- | | ||
for file in `ls vendor/**/*.node`; do | ||
parent=${file%/*}; | ||
name=${parent##*/}; | ||
fullyQualifiedName="$(pwd)/$parent/${name}_binding.node"; | ||
mv "$file" "$parent/${name}_binding.node"; | ||
echo -e "New filename\072 $fullyQualifiedName"; | ||
./scripts/upload-github-release-asset.sh github_api_token=$GH_API_TOKEN owner=sass repo=node-sass tag=$CIRRUS_TAG filename=$fullyQualifiedName; | ||
done |
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,7 @@ | ||
FreeBSD: { | ||
url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest", | ||
mirror_type: "srv", | ||
signature_type: "fingerprints", | ||
fingerprints: "/usr/share/keys/pkg", | ||
enabled: yes | ||
} |
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,85 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o xtrace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I planned to rewrite both of those shell scripts but forgot about them (didn't test upload either). Resetting to draft. Thanks! |
||
|
||
jailName=$1 | ||
skelDirectory=$2 | ||
cbsd_workdir=/usr/jails | ||
jail_arch="i386" | ||
jail_ver="11.3" | ||
|
||
# determine uplink ip address | ||
# determine uplink iface | ||
echo "Interface configuration:" | ||
/sbin/ifconifg -a | ||
auto_iface=$( /sbin/route -n get 0.0.0.0 |/usr/bin/awk '/interface/{print $2}' ) | ||
my_ipv4=$( /sbin/ifconfig ${auto_iface} | /usr/bin/awk '/inet [0-9]+/{print $2}' ) | ||
|
||
if [ -z "${my_ipv4}" ]; then | ||
echo "IPv4 not detected" | ||
exit 1 | ||
fi | ||
echo "IPv4 routing table:" | ||
netstat -rnf inet | ||
echo "IPv6 routing table:" | ||
netstat -rnf inet6 | ||
echo "${auto_iface} has been selected, with ${my_ipv4} IPv4 address" | ||
|
||
echo "Writing '${jailName}' configuration file" | ||
cat > /tmp/${jailName}.jconf << EOF | ||
jname="${jailName}" | ||
path="${cbsd_workdir}/${jailName}" | ||
host_hostname="${jailName}.my.domain" | ||
ip4_addr="${my_ipv4}" | ||
mount_devfs="1" | ||
allow_mount="1" | ||
allow_devfs="1" | ||
allow_nullfs="1" | ||
allow_raw_sockets="1" | ||
mount_fstab="${cbsd_workdir}/jails-fstab/fstab.${jailName}" | ||
arch="${jail_arch}" | ||
mkhostsfile="1" | ||
devfs_ruleset="4" | ||
ver="${jail_ver}" | ||
basename="" | ||
baserw="0" | ||
mount_src="0" | ||
mount_obj="0" | ||
mount_kernel="0" | ||
mount_ports="1" | ||
astart="1" | ||
data="${cbsd_workdir}/jails-data/${jailName}-data" | ||
vnet="0" | ||
applytpl="1" | ||
mdsize="0" | ||
rcconf="${cbsd_workdir}/jails-rcconf/rc.conf_${jailName}" | ||
floatresolv="1" | ||
exec_poststart="0" | ||
exec_poststop="" | ||
exec_prestart="0" | ||
exec_prestop="0" | ||
exec_master_poststart="0" | ||
exec_master_poststop="0" | ||
exec_master_prestart="0" | ||
exec_master_prestop="0" | ||
pkg_bootstrap="1" | ||
interface="0" | ||
jailskeldir="$skelDirectory" | ||
exec_start="/bin/sh /etc/rc" | ||
exec_stop="/bin/sh /etc/rc.shutdown" | ||
EOF | ||
|
||
echo "Initializing cbsd environment" | ||
env workdir=${cbsd_workdir} /usr/local/cbsd/sudoexec/initenv /usr/local/cbsd/share/initenv.conf | ||
|
||
echo "Creating ${jailName}" | ||
cbsd jcreate jconf=/tmp/${jailName}.jconf inter=0 | ||
cbsd jailscp /etc/resolv.conf ${jailName}:/etc/resolv.conf | ||
|
||
cat > ~cbsd/jails-fstab/fstab.${jailName}.local <<EOF | ||
${skelDirectory} /etc/skel nullfs rw 0 0 | ||
EOF | ||
|
||
cbsd jstart jname=${jailName} inter=0 | ||
|
||
echo "${jailName} created" |
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,60 @@ | ||
#!/usr/bin/env sh | ||
# | ||
# Modified version of: https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 | ||
# | ||
# | ||
# This script accepts the following parameters: | ||
# | ||
# * owner | ||
# * repo | ||
# * tag | ||
# * filename | ||
# * github_api_token | ||
# | ||
# Script to upload a release asset using the GitHub API v3. | ||
# | ||
# Example: | ||
# | ||
# upload-github-release-asset.sh github_api_token=TOKEN owner=stefanbuck repo=playground tag=v0.1.0 filename=./build.zip | ||
# | ||
|
||
set -e | ||
|
||
# Validate settings. | ||
[ "$TRACE" ] && set -x | ||
|
||
for line in "$@"; do | ||
eval "$line" | ||
done | ||
|
||
# Define variables. | ||
GH_API="https://api.github.com" | ||
GH_REPO="$GH_API/repos/$owner/$repo" | ||
GH_RELEASES="$GH_REPO/releases" | ||
GH_TAGS="$GH_RELEASES/tags/$tag" | ||
AUTH="Authorization: token $github_api_token" | ||
|
||
if test "$tag" == "LATEST"; then | ||
GH_TAGS="$GH_REPO/releases/latest" | ||
fi | ||
|
||
# Validate token. | ||
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; } | ||
|
||
# Create a release from tag if it does not exist. | ||
curl -s -d "{\"tag_name\":\"$tag\"}" -H "$AUTH" "$GH_RELEASES" > /dev/null | ||
|
||
# Read asset tags. | ||
response=$(curl -sH "$AUTH" $GH_TAGS) | ||
|
||
# Get ID of the asset based on given filename. | ||
eval "$(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')" | ||
[ -n "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response" | awk 'length($0)<100' >&2; exit 1; } | ||
|
||
# Upload asset | ||
echo "Uploading asset... " | ||
|
||
# Construct url | ||
GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$(basename $filename)" | ||
|
||
curl "$GITHUB_OAUTH_BASIC" --data-binary @"$filename" -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we expand out the matrix to the other versions we currently list as supported for FreeBSD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I forgot it. Back to work :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can limit this to v5 also to make our lives a bit easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been only building binaries for node version currently in the FreeBSD ports tree, which are 10, 12 and 13 now. Pushed the commit to expand the matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop 10 now, but it would be good to try and get 12, 14, 16, 17 to match the other platforms