Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to run a Github Actions runner to test Go Rest API Server?

I have a github actions file. I am just building the go application, which is a rest API server and running couple of tests in the test folder. But in github actions runner, it is stuck on the "start server" step indefinitely.It is not going to the test step. If I understand it correctly, the api server is running indefinitely listening to requests and not not going to next step. Kindly assist how I can run the below tests step.

name: Continuous Integration

on:
  push:
    branches:
      - "main"
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: checkout repository
        uses: actions/checkout@v2
      - name: Setup Go
        uses: actions/setup-go@v4
        with:
          go-version: 1.20.7
      - name: build
        run: go build -o main
      - name: change permissions
        run: chmod +x main
      - name: start server
        run: ./main
      - name: test
        run: go test -v ./tests

Below is the output of the actions runner.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Seems the start server step will lock the execution (active wait). so the test step is never reached (and a timeout is fired). In that case you can execute the server command in background like ./main &

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading