Force IPv6 disablement in mDNSResponder compilation #157
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
name: ci-build-test-publish | |
on: | |
push: | |
branches: [dev, master] | |
pull_request: | |
branches: [dev, master] | |
workflow_dispatch: | |
env: | |
SECRET_GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
SECRET_RESULTS_SHEET_ID: ${{ secrets.RESULTS_SHEET_ID }} | |
jobs: | |
docker-buildx-test-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v2 | |
- name: Set environment variables | |
shell: bash | |
run: | | |
GITHUB_COMMIT=`sed -n 's/.*NMOS_CPP_VERSION=\(.......\).*/\1/p' Dockerfile` | |
echo "GITHUB_COMMIT=$GITHUB_COMMIT" >> $GITHUB_ENV | |
GITHUB_BRANCH=`echo "${{ github.ref }}" | cut -d'/' -f3` | |
echo "GITHUB_BRANCH=$GITHUB_BRANCH" >> $GITHUB_ENV | |
echo "GITHUB_WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV | |
echo "RUNNER_WORKSPACE=${{ runner.workspace }}" >> $GITHUB_ENV | |
echo "BUILD_NAME=ubuntu-latest_avahi" >> $GITHUB_ENV | |
echo "TEST_FAIL=FALSE" >> $GITHUB_ENV | |
- name: Set docker image name | |
shell: bash | |
run: | | |
if [[ "${{ secrets.Docker_Image_Name }}" ]]; then | |
echo "DOCKER_IMAGE_NAME=${{ secrets.Docker_Image_Name }}" >> $GITHUB_ENV | |
else | |
echo "DOCKER_IMAGE_NAME=rhastie/nmos-cpp" >> $GITHUB_ENV | |
fi | |
- name: Set platforms and tags | |
shell: bash | |
run: | | |
if [[ "${{ secrets.BUILD_PLATFORMS }}" ]] && [[ "${{ env.GITHUB_BRANCH }}" == "master" ]]; then | |
echo "BUILD_PLATFORMS=${{ secrets.BUILD_PLATFORMS }}" >> $GITHUB_ENV | |
else | |
echo "BUILD_PLATFORMS=linux/amd64" >> $GITHUB_ENV | |
fi | |
if [[ "${{ secrets.PUSH_LATEST }}" == "TRUE" ]] && [[ "${{ env.GITHUB_BRANCH }}" == "master" ]]; then | |
echo "BUILD_TAGS=${{ env.GITHUB_BRANCH }}-${{ env.GITHUB_COMMIT }},latest" >> $GITHUB_ENV | |
else | |
echo "BUILD_TAGS=${{ env.GITHUB_BRANCH }}-${{ env.GITHUB_COMMIT }}" >> $GITHUB_ENV | |
fi | |
- name: Setup Google credentials | |
if: env.SECRET_GOOGLE_CREDENTIALS | |
shell: bash | |
working-directory: ${{ env.GITHUB_WORKSPACE }} | |
run: | | |
mkdir -p gdrive | |
echo "${{ env.SECRET_GOOGLE_CREDENTIALS }}" | openssl base64 -d -A -out gdrive/credentials.json | |
echo "GDRIVE_CREDENTIALS=`pwd`/gdrive/credentials.json" >> $GITHUB_ENV | |
- name: Get IP Host Address | |
run: | | |
hostip=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') | |
echo "HOST_IP_ADDRESS=$hostip" >> $GITHUB_ENV | |
echo "Using HOST IP Address: $hostip" | |
ip address | |
- name: Available Docker Buildx platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Docker Buildx and load x86 image to Docker images | |
uses: ilteoood/docker_buildx@master | |
with: | |
dockerfile: Dockerfile | |
publish: false | |
load: true | |
imageName: ${{ env.DOCKER_IMAGE_NAME }} | |
tag: ${{ env.GITHUB_BRANCH }} | |
buildArg: makemt=3 | |
platform: linux/amd64 | |
- name: List docker images | |
shell: bash | |
run: docker images | |
- name: Ubuntu avahi and mosquitto-clients setup | |
run: | | |
sudo apt-get update | |
sudo apt-get install -f libavahi-compat-libdnssd-dev mosquitto-clients | |
# make avahi only respond on the "eth0" interface | |
sudo sed -i 's/#*allow-interfaces=.*/allow-interfaces=eth0/g' /etc/avahi/avahi-daemon.conf | |
sudo systemctl restart avahi-daemon | |
- name: Install python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.8 | |
- name: Install pip | |
run: | | |
python -m pip install --upgrade pip | |
- name: Configure node.json and registry.json files for tests and .local mDNS domain | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | | |
echo "{\"pri\":0, \"http_port\":11000, \"how_many\":6, \"domain\":\"local.\", \"logging_level\":0}" > $(pwd)/node.json | |
echo "{\"pri\":0, \"http_port\":8010, \"domain\":\"local.\", \"logging_level\":0}" > $(pwd)/registry.json | |
cat $(pwd)/node.json $(pwd)/registry.json | |
- name: Remove IP Address from Docker0 to force AMWA Test Suite mDNS to use eth0 | |
run: sudo ip address del 172.17.0.1/16 dev docker0 || echo "Docker IP Address del failed" | |
- name: Start Node Docker container for Node tests | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: docker run -it -d --net=host --name nmos-cpp-node -v="$(pwd)/node.json:/home/node.json" -e "RUN_NODE=TRUE" ${{ env.DOCKER_IMAGE_NAME }}:${{ env.GITHUB_BRANCH }} | |
- name: Install AMWA Test suite | |
shell: bash | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | |
| | |
set -x | |
root_dir=`pwd` | |
# Install AMWA test suite. | |
git clone https://github.com/AMWA-TV/nmos-testing.git | |
cd nmos-testing | |
# Create output directories | |
mkdir results | |
mkdir badges | |
# run test suite directly | |
pip install wheel | |
pip install -r requirements.txt | |
# Install SDPoker | |
npm install -g git+https://git@github.com/AMWA-TV/sdpoker.git | |
pip install -r utilities/run-test-suites/gsheetsImport/requirements.txt | |
- name: Run AMWA Test suite against Node | |
shell: bash | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | |
| | |
set -x | |
root_dir=`pwd` | |
# Set AMWA Test suite runtime executable path | |
run_test="python nmos-test.py" | |
cd nmos-testing | |
function do_run_test() { | |
suite=$1 | |
shift | |
case $($run_test suite ${suite} --selection all "$@" --output "results/${{ env.GITHUB_COMMIT }}-${{ env.BUILD_NAME }}-${{ env.GITHUB_BRANCH }}-${suite}.json" >> results/testoutput 2>&1; echo $?) in | |
[0-1]) echo "Pass" > badges/${suite}.txt ;; | |
*) echo "Fail" > badges/${suite}.txt; echo "TEST_FAIL=TRUE" >> $GITHUB_ENV ;; | |
esac | |
} | |
do_run_test IS-04-01 --host "${{ env.HOST_IP_ADDRESS }}" --port 11000 --version v1.3 | |
do_run_test IS-04-03 --host "${{ env.HOST_IP_ADDRESS }}" --port 11000 --version v1.3 | |
do_run_test IS-05-01 --host "${{ env.HOST_IP_ADDRESS }}" --port 11000 --version v1.1 | |
do_run_test IS-05-02 --host "${{ env.HOST_IP_ADDRESS }}" "${{ env.HOST_IP_ADDRESS }}" --port 11000 11000 --version v1.3 v1.1 | |
do_run_test IS-07-01 --host "${{ env.HOST_IP_ADDRESS }}" --port 11000 --version v1.0 | |
do_run_test IS-07-02 --host "${{ env.HOST_IP_ADDRESS }}" "${{ env.HOST_IP_ADDRESS }}" "${{ env.HOST_IP_ADDRESS }}" --port 11000 11000 11000 --version v1.3 v1.1 v1.0 | |
do_run_test IS-08-01 --host "${{ env.HOST_IP_ADDRESS }}" --port 11000 --version v1.0 --selector null | |
do_run_test IS-08-02 --host "${{ env.HOST_IP_ADDRESS }}" "${{ env.HOST_IP_ADDRESS }}" --port 11000 11000 --version v1.3 v1.0 --selector null null | |
do_run_test IS-09-02 --host "${{ env.HOST_IP_ADDRESS }}" null --port 0 0 --version null v1.0 | |
echo ${{ env.TEST_FAIL }} | |
exit 0 | |
- name: Start Registry Docker container and re-start Node Docker container for Registry tests | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | | |
docker container stop nmos-cpp-node | |
docker container rm nmos-cpp-node | |
docker run -it -d --net=host --name nmos-cpp-registry -v="$(pwd)/registry.json:/home/registry.json" -e "RUN_NODE=FALSE" ${{ env.DOCKER_IMAGE_NAME }}:${{ env.GITHUB_BRANCH }} | |
sleep 5 | |
docker run -it -d --net=host --name nmos-cpp-node -v="$(pwd)/node.json:/home/node.json" -e "RUN_NODE=TRUE" ${{ env.DOCKER_IMAGE_NAME }}:${{ env.GITHUB_BRANCH }} | |
- name: Run AMWA Test suite against Registry | |
shell: bash | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | |
| | |
set -x | |
root_dir=`pwd` | |
# Set AMWA Test suite runtime executable path | |
run_test="python nmos-test.py" | |
cd nmos-testing | |
function do_run_test() { | |
suite=$1 | |
shift | |
case $($run_test suite ${suite} --selection all "$@" --output "results/${{ env.GITHUB_COMMIT }}-${{ env.BUILD_NAME }}-${{ env.GITHUB_BRANCH }}-${suite}.json" >> results/testoutput 2>&1; echo $?) in | |
[0-1]) echo "Pass" > badges/${suite}.txt ;; | |
*) echo "Fail" > badges/${suite}.txt; echo "TEST_FAIL=TRUE" >> $GITHUB_ENV ;; | |
esac | |
} | |
# short delay to give the Registry a chance to start up and the Node a chance to register before running the Registry test suite | |
sleep 2 | |
# add a persistent Query WebSocket API subscription before running the Registry test suite | |
curl "http://localhost:8010/x-nmos/query/v1.3/subscriptions" -H "Content-Type: application/json" -d "{\"max_update_rate_ms\": 100, \"resource_path\": \"/nodes\", \"params\": {\"label\": \"host1\"}, \"persist\": true, \"secure\": false}" | |
do_run_test IS-04-02 --host "${{ env.HOST_IP_ADDRESS }}" "${{ env.HOST_IP_ADDRESS }}" --port 8010 8010 --version v1.3 v1.3 | |
do_run_test IS-09-01 --host "${{ env.HOST_IP_ADDRESS }}" --port 8010 --version v1.0 | |
echo ${{ env.TEST_FAIL }} | |
exit 0 | |
- name: Test MQTT Broker for basic connectivity and function | |
shell: bash | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | |
| | |
set -x | |
mqtt_error=FALSE | |
cd nmos-testing | |
# Start a subscriber, connect to MQTT Broker and listen on topic | |
mosquitto_sub -h "${{ env.HOST_IP_ADDRESS }}" -p 1883 -t test -C 1 > ./mqtt_pub_output & | |
if [ $? -ne 0 ]; then | |
mqtt_error=TRUE | |
fi | |
sleep 1 | |
# Start a publisher, connect to MQTT Broker and post a message | |
mosquitto_pub -h "${{ env.HOST_IP_ADDRESS }}" -p 1883 -t test -m "Ping MQTT test" | |
if [ $? -ne 0 ]; then | |
mqtt_error=TRUE | |
fi | |
# Short delay to allow connections, transfer of message and closure of subscriber | |
sleep 1 | |
sub_output=$(cat ./mqtt_pub_output) | |
rm ./mqtt_pub_output | |
#Check if we got the expected message from the subscriber | |
if [ "$sub_output" == 'Ping MQTT test' ] && [ "$mqtt_error" == 'FALSE' ]; then | |
echo "Passed MQTT Broker Test" | |
echo "Pass" > badges/MQTT-Broker.txt | |
else | |
echo "Failed MQTT Broker Test" | |
echo "Fail" > badges/MQTT-Broker.txt | |
fi | |
exit 0 | |
- name: Stop Registry and Node containers | |
shell: bash | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
run: | |
| | |
docker container stop nmos-cpp-registry | |
docker container stop nmos-cpp-node | |
docker container rm nmos-cpp-registry | |
docker container rm nmos-cpp-node | |
- name: Re-add IP address for Docker0 interface | |
run: | |
| | |
sudo ip address add 172.17.0.1/16 broadcast 172.17.255.255 dev docker0 || echo "Docker IP Address add failed" | |
ip address | |
- name: If Passes tests, Docker Buildx and publish x86 image to Docker Hub | |
if: env.TEST_FAIL == 'FALSE' && (env.GITHUB_BRANCH == 'master' || env.GITHUB_BRANCH == 'dev') | |
uses: ilteoood/docker_buildx@master | |
with: | |
dockerfile: Dockerfile | |
publish: true | |
load: false | |
imageName: ${{ env.DOCKER_IMAGE_NAME }} | |
tag: ${{ env.BUILD_TAGS }} | |
buildArg: makemt=3 | |
platform: ${{ env.BUILD_PLATFORMS }} | |
dockerUser: ${{ secrets.DockerHub_User }} | |
dockerPassword: ${{ secrets.DockerHub_Password }} | |
- name: Upload results to google sheets | |
if: env.TEST_FAIL == 'FALSE' && (env.GITHUB_BRANCH == 'master' || env.GITHUB_BRANCH == 'dev') | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
shell: bash | |
run: | | |
# Move to nmos-testing/results directory and operate relative to truncate "filenames in spreadsheet" | |
cd nmos-testing/results | |
export SHEET=https://docs.google.com/spreadsheets/d/${{ env.SECRET_RESULTS_SHEET_ID }} | |
python ../utilities/run-test-suites/gsheetsImport/resultsImporter.py --credentials ${{ env.GDRIVE_CREDENTIALS }} --sheet "$SHEET" --insert --json ${{ env.GITHUB_COMMIT }}-*.json || echo "upload failed" | |
# - name: If Passes tests and branch == master, update Docker Hub README file using GitHub README.md | |
# if: env.TEST_FAIL == 'FALSE' && env.GITHUB_BRANCH == 'master' | |
# uses: meeDamian/sync-readme@v1.0.6 | |
# with: | |
# user: ${{ secrets.DockerHub_User }} | |
# pass: ${{ secrets.DockerHub_Password }} | |
# slug: ${{ env.DOCKER_IMAGE_NAME }} | |
- name: If Passes tests, build image file of x86 container | |
if: env.TEST_FAIL == 'FALSE' | |
working-directory: ${{ env.RUNNER_WORKSPACE }} | |
shell: bash | |
run: | | |
# Make directory and build image from container in Docker image repository | |
mkdir container-image | |
cd container-image | |
docker save ${{ env.DOCKER_IMAGE_NAME }}:${{ env.GITHUB_BRANCH }}| gzip > nmos-cpp_${{ env.GITHUB_BRANCH }}-${{ env.GITHUB_COMMIT }}.img.tar.gz | |
- name: If Passes tests, upload container image as an artifact | |
if: env.TEST_FAIL == 'FALSE' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.BUILD_NAME }}_container | |
path: ${{ runner.workspace }}/container-image/nmos-cpp_${{ env.GITHUB_BRANCH }}-${{ env.GITHUB_COMMIT }}.img.tar.gz | |
- name: Upload badges as artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.BUILD_NAME }}_badges | |
path: ${{ runner.workspace }}/nmos-testing/badges | |
- name: Upload results as artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.BUILD_NAME }}_results | |
path: ${{ runner.workspace }}/nmos-testing/results | |
make-badges: | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
needs: docker-buildx-test-publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: set environment variables | |
shell: bash | |
run: | | |
GITHUB_COMMIT=`echo "${{ github.sha }}" | cut -c1-7` | |
echo "GITHUB_COMMIT=$GITHUB_COMMIT" >> $GITHUB_ENV | |
echo "GITHUB_WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV | |
echo "RUNNER_WORKSPACE=${{ runner.workspace }}" >> $GITHUB_ENV | |
- uses: actions/download-artifact@v2 | |
with: | |
path: ${{ runner.workspace }}/artifacts | |
- name: make badges | |
run: | | |
# combine badges from all builds | |
${{ github.workspace }}/.github/scripts/make_badges.sh ${{ github.workspace }} ${{ runner.workspace }}/artifacts | |
# force push to github onto an orphan 'badges' branch | |
cd ${{ github.workspace }} | |
git checkout --orphan badges-${{ env.GITHUB_COMMIT }} | |
git rm -rfq --ignore-unmatch . | |
git add *.svg | |
git remote set-url --push `git remote` https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }} | |
git config --global user.name 'test-results-uploader' | |
git config --global user.email 'test-results-uploader@nmos-cpp.iam.gserviceaccount.com' | |
git commit -qm "Badges for README at ${{ env.GITHUB_COMMIT }}" | |
git push -f `git remote` badges-${{ env.GITHUB_COMMIT }}:badges |