diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 000000000..4b21f092f --- /dev/null +++ b/.cirrus.yml @@ -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 diff --git a/.cirrus/pkg/repos/FreeBSD.conf b/.cirrus/pkg/repos/FreeBSD.conf new file mode 100644 index 000000000..4a9614d56 --- /dev/null +++ b/.cirrus/pkg/repos/FreeBSD.conf @@ -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 +} diff --git a/scripts/configure_freebsd_ci_jail.sh b/scripts/configure_freebsd_ci_jail.sh new file mode 100755 index 000000000..ba430ab1e --- /dev/null +++ b/scripts/configure_freebsd_ci_jail.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env sh + +set -o xtrace + +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 < /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