Skip to content

Build Semi-Static Binary #1

Build Semi-Static Binary

Build Semi-Static Binary #1

Workflow file for this run

name: Build Semi-Static Binary
on:
workflow_dispatch:
inputs:
release_type:
required: true
type: string
workflow_call:
inputs:
release_type:
required: true
type: string
secrets:
GCP_CREDENTIALS:
required: true
jobs:
static:
name: Antique Build
strategy:
fail-fast: false
matrix:
include:
- arch: ubuntu-latest
image: ghcr.io/viamrobotics/antique2:amd64-cache
platform: linux/amd64
- arch: buildjet-2vcpu-ubuntu-2204-arm
image: ghcr.io/viamrobotics/antique2:arm64-cache
platform: linux/arm64
runs-on: ${{ matrix.arch }}
container:
image: ${{ matrix.image }}
options: --platform ${{ matrix.platform }}
timeout-minutes: 15
outputs:
date: ${{ steps.build_date.outputs.date }}
steps:
- name: Check out code
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: actions/checkout@v3
- name: Check out PR branch code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Clean and Fix Permissions
run: |
chown -R testbot:testbot .
sudo -Hu testbot bash -lc 'make clean-all'
- name: Authorize GCP Upload
uses: google-github-actions/[email protected]
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Build (PR)
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" static-release'
- name: Upload Files (PR)
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/static/deploy/'
destination: 'packages.viam.com/apps/viam-server/'
glob: 'viam-server-*'
parent: false
gzip: false
- name: Build (Latest)
if: inputs.release_type == 'latest'
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="latest" static-release'
- name: Build (Tagged)
if: inputs.release_type == 'stable' || inputs.release_type == 'rc'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" static-release'
- name: Set Date
id: build_date
run: echo "date=`date +%F`" >> $GITHUB_OUTPUT
- name: Upload Files (Testing)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/static/deploy/'
destination: 'packages.viam.com/apps/viam-server/testing/static/${{ steps.build_date.outputs.date }}/${{ github.sha }}/'
glob: 'viam-server-*'
parent: false
gzip: false
- name: Upload Manifest (Testing)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/static/manifest/'
destination: 'packages.viam.com/apps/viam-subsystems/testing/viam-server/${{ steps.build_date.outputs.date }}/${{ github.sha }}/'
glob: 'viam-server-*'
parent: false
gzip: false
output_summary:
name: Output Summary
runs-on: ubuntu-latest
needs: static
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
steps:
- name: Output Summary
run: |
channel="pr-${{ github.event.pull_request.number }}"
echo "### Built Static Binaries for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
static_test:
name: Static Test
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
arch: [[ubuntu-latest], [buildjet-2vcpu-ubuntu-2204-arm], [arm64, pi4]]
needs: static
runs-on: ${{ matrix.arch }}
timeout-minutes: 15
outputs:
date: ${{ needs.static.outputs.date }}
steps:
- name: Clean Workspace
run: |
shopt -s dotglob
sudo chown -R `whoami` ./
rm -rf ./*
- name: Test Static Binary
run: |
channel="${{ github.ref_name }}"
# we call our main branch releases "latest"
if [ "$channel" = "main" ]; then
channel="latest"
fi
export TEST_DIR=`mktemp -d -t test-viam-server-XXXXXX`
cd $TEST_DIR
curl --fail -o viam-server https://storage.googleapis.com/packages.viam.com/apps/viam-server/testing/static/${{ needs.static.outputs.date }}/${{ github.sha }}/viam-server-${channel}-`uname -m`
chmod 755 viam-server
export RAND_PORT=$((30000 + $RANDOM))
echo "{\"network\": {\"bind_address\":\"localhost:${RAND_PORT}\"}}" > test.json
./viam-server -config test.json &
curl --retry 5 --retry-delay 5 --retry-connrefused localhost:$RAND_PORT
export RET1=$?
kill %%
wait $!
export RET2=$?
cd - && rm -rf $TEST_DIR
[ $RET1 == 0 ] && [ $RET1 == 0 ]
static_deploy:
name: Static Deploy
needs: static_test
runs-on: ubuntu-latest
steps:
- name: Authorize GCP
uses: google-github-actions/[email protected]
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Publish Static Binary
run: |
gsutil mv "gs://packages.viam.com/apps/viam-server/testing/static/${{ needs.static_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-server/"
- name: Publish Subsystem Metadata
run: |
gsutil mv "gs://packages.viam.com/apps/viam-subsystems/testing/viam-server/${{ needs.static_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-subsystems/"
- name: Output Summary
run: |
channel="${{ github.ref_name }}"
# we call our main branch releases "latest"
if [ "$channel" == "main" ]; then
channel="latest"
fi
echo "### Built Static Binaries for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY