Hack - Run unit tests on Alabaster
This commit is contained in:
parent
3058dc48a8
commit
19570f733f
41
.github/workflows/on-pr.yaml
vendored
41
.github/workflows/on-pr.yaml
vendored
@ -14,24 +14,41 @@ jobs:
|
|||||||
name: Run unit tests
|
name: Run unit tests
|
||||||
env:
|
env:
|
||||||
GOPATH: /tmp/go
|
GOPATH: /tmp/go
|
||||||
|
HOSTNAME: ${{ secrets.BUILD_HOSTNAME }}
|
||||||
|
USERNAME: ${{ secrets.BUILD_USERNAME }}
|
||||||
|
PRIVATE_KEY: ${{ secrets.BUILD_KEY }}
|
||||||
|
PASSWORD: ${{ secrets.BUILD_PASSWORD}}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.16.x, 1.17.x]
|
go-version: [1.16.x, 1.17.x]
|
||||||
runs-on: self-hosted
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Create GOPATH
|
|
||||||
run: mkdir -p /tmp/go
|
|
||||||
- name: Install Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ${{ matrix.go-version }}
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Run database
|
|
||||||
run: docker-compose up -d ipld-eth-db
|
- name: Install sshpass
|
||||||
- name: Test
|
run: sudo apt-get install -y sshpass
|
||||||
|
|
||||||
|
# Passed experience with GHA has taught me to store variables in files instead of passing them as variables.
|
||||||
|
- name: SCP necessary variables to the server
|
||||||
run: |
|
run: |
|
||||||
sleep 10
|
echo ${{ env.GITHUB_REPOSITORY}} > /tmp/git_repository
|
||||||
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test
|
echo ${{ env.GITHUB_HEAD_REF}} > /tmp/git_head_ref
|
||||||
|
echo ${{ env.PRIVATE_KEY }} | sshpass -p ${{ env.PASSWORD }} scp -i /dev/stdin /tmp/git_repository {{ env.USERNAME }}@${{ env.HOSTNAME }}:/tmp/git_repository
|
||||||
|
echo ${{ env.PRIVATE_KEY }} | sshpass -p ${{ env.PASSWORD }} scp -i /dev/stdin /tmp/git_head_ref {{ env.USERNAME }}@${{ env.HOSTNAME }}:/tmp/git_head_ref
|
||||||
|
echo ${{ env.PRIVATE_KEY }} | sshpass -p ${{ env.PASSWORD }} scp -i /dev/stdin ./github/workflows/run_unit_test.sh {{ env.USERNAME }}@${{ env.HOSTNAME }}:/tmp/run_unit_test.sh
|
||||||
|
|
||||||
|
- name: Trigger Unit Test
|
||||||
|
run: echo ${{ env.PRIVATE_KEY }} | sshpass -p ${{ env.PASSWORD }} ssh {{ env.USERNAME }}@{{ env.HOSTNAME }} -i /dev/stdin /tmp/run_unit_test.sh
|
||||||
|
|
||||||
|
- name: Get the logs and cat them
|
||||||
|
run: |
|
||||||
|
echo ${{ env.PRIVATE_KEY }} | sshpass -p ${{ env.PASSWORD }} scp -i /dev/stdin {{ env.USERNAME }}@${{ env.HOSTNAME }}:/tmp/test.log .
|
||||||
|
cat ./test.log
|
||||||
|
|
||||||
|
- name: Check Error Code
|
||||||
|
run: |
|
||||||
|
echo ${{ env.PRIVATE_KEY }} | sshpass -p ${{ env.PASSWORD }} scp -i /dev/stdin {{ env.USERNAME }}@${{ env.HOSTNAME }}:/tmp/return_test.txt .
|
||||||
|
[ $(cat ./return_test.txt) -eq 0 ]
|
||||||
|
|
||||||
integrationtest:
|
integrationtest:
|
||||||
name: Run integration tests
|
name: Run integration tests
|
||||||
|
29
.github/workflows/run_unit_test.sh
vendored
Normal file
29
.github/workflows/run_unit_test.sh
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Set up repo
|
||||||
|
start_dir=$(pwd)
|
||||||
|
temp_dir=$(mktemp -d)
|
||||||
|
cd $temp_dir
|
||||||
|
git clone -b $(cat /tmp/git_head_ref) "https://github.com/$(cat /tmp/git_repository).git"
|
||||||
|
cd ipld-eth-server
|
||||||
|
|
||||||
|
## Remove the branch and github related info. This way future runs wont be confused.
|
||||||
|
rm -f /tmp/git_head_ref /tmp/git_repository
|
||||||
|
|
||||||
|
# Spin up DB
|
||||||
|
docker-compose up -d ipld-eth-db
|
||||||
|
trap "docker-compose down --remove-orphans; cd $start_dir ; rm -r $temp_dir" SIGINT SIGTERM ERR
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Remove old logs so there's no confusion, then run test
|
||||||
|
rm -f /tmp/test.log /tmp/return_test.txt
|
||||||
|
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test > /tmp/test.log
|
||||||
|
echo $? > /tmp/return_test.txt
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
docker-compose down -v --remove-orphans
|
||||||
|
cd $start_dir
|
||||||
|
rm -fr $temp_dir
|
||||||
|
|
Loading…
Reference in New Issue
Block a user