node-api/.gitea/workflows/unittests.yml

60 lines
1.8 KiB
YAML
Raw Normal View History

2023-11-25 18:16:53 +00:00
name: Unittests
on:
push:
branches: [main]
workflow_dispatch: {}
jobs:
unittests:
runs-on: [amd64, moon]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: 1.21
2023-11-25 18:32:04 +00:00
- name: start minio
run: |
2023-11-25 18:36:28 +00:00
docker run -d --rm --name nodeapi_minio -p 9000:9000 -p 9001:9001 -e MINIO_ROOT_USER=test -e MINIO_ROOT_PASSWORD=testtest minio/minio:latest server /data --console-address :9001
2023-11-25 18:37:59 +00:00
- name: deps
run: apt update && apt install -y tar zstd
2023-11-25 18:16:53 +00:00
- name: Test
run: |
make test
2023-11-25 18:32:04 +00:00
- name: stop minio
2023-11-25 18:33:20 +00:00
if: always()
2023-11-25 18:32:04 +00:00
run: |
docker stop nodeapi_minio
# TODO: probably not supported by Gitea workflows yet
# services:
# minio:
# image: minio/minio:latest
# env:
# MINIO_ROOT_USER: test
# MINIO_ROOT_PASSWORD: testtest
# ports:
# - 9001:9001
# options: server /data --console-address :9001
2023-11-25 18:16:53 +00:00
deploy-dev:
2023-11-25 18:19:49 +00:00
runs-on: [amd64, moon]
env:
NODES: 192.168.1.236 192.168.1.220
steps:
2023-11-25 18:18:40 +00:00
- name: deploy
2023-11-25 18:16:53 +00:00
run: |
docker run --rm --privileged -ti -v ${shell pwd}:/srv golang:1.20-buster /bin/sh -c "cd /srv && go build"
2023-11-25 18:19:49 +00:00
2023-11-25 18:16:53 +00:00
ssh -o StrictHostKeyChecking=accept-new root@$HOST echo "Setting up host keys"
for NODE in $NODES; do
echo "\033[0;32mDeploying $NODE\033[0m"
echo "\033[1;33m.. scanning SSH keys\033[0m"
ssh-keyscan $NODE > ~/.ssh/known_hosts
echo "\033[1;33m.. copying the binary\033[0m"
scp node-api root@$NODE:/usr/local/bin/node-api_
echo "\033[1;33m.. replacing the binary\033[0m"
ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
echo "\033[1;33m.. restarting service\033[0m"
ssh root@$NODE systemctl restart node-api
done