Skip to content

build client

build client #28

Workflow file for this run

name: Tests
on: [push]
env:
IMAGE_NAME: coap
IMAGE_TAGGED: coap:${{ github.sha }}
REPO_IMAGE_TAGGED: ${{ vars.REGISTRY_LOGIN_SERVER }}/coap:${{ github.sha }}
REPO_IMAGE_LATEST: ${{ vars.REGISTRY_LOGIN_SERVER }}/coap:latest
jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
- name: Build server
working-directory: server
run: go build
- name: Build image
run: |
docker build -t ${{ env.IMAGE_TAGGED }} .
- name: Log in to the infrastructure container registry
run: |
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_LOGIN_SERVER }}
- name: Push image to the infrastructure container registry
run: |
docker tag ${{ env.IMAGE_TAGGED }} ${{ env.REPO_IMAGE_TAGGED }}
docker push ${{ env.REPO_IMAGE_TAGGED }}
tests:
needs: [image]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
- name: Build client
working-directory: client
run: go build
- name: Log in to infrastructure container registry
run: |
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_LOGIN_SERVER }}
- name: Pull image from the infrastructure container registry
run: |
docker pull ${{ env.REPO_IMAGE_TAGGED }}
- name: Run image
env:
STORAGE_CONNECTION_STRING: ${{ secrets.STORAGE_CONNECTION_STRING }}
STORAGE_CONTAINER_NAME: ${{ vars.STORAGE_CONTAINER_NAME }}
run: |
docker run --network=host -p 5688:5688/udp -p 5689:5689/udp -e STORAGE_CONNECTION_STRING -e STORAGE_CONTAINER_NAME -d ${{ env.REPO_IMAGE_TAGGED }}
- run: docker ps
- run: docker container logs `docker ps | grep ${{ env.IMAGE_TAGGED }} | awk '{ print $1; }'`
- name: Run test client (IPv4)
working-directory: client
run: ./coap-client
- name: Run test client (IPv6)
working-directory: client
run: ./coap-client -udp6
- name: Docker logs
if: always()
run: |
docker ps
docker container logs `docker ps | grep ${{ env.IMAGE_TAGGED }} | awk '{ print $1; }'`
publish:
if: github.ref == 'refs/heads/saga'
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Log in to infrastructure container registry
run: |
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_LOGIN_SERVER }}
- name: Pull image from the infrastructure container registry
run: |
docker pull ${{ env.REPO_IMAGE_TAGGED }}
- name: Push image to the infrastructure container registry as latest
run: |
docker tag ${{ env.REPO_IMAGE_TAGGED }} ${{ env.REPO_IMAGE_LATEST }}
docker push ${{ env.REPO_IMAGE_LATEST }}