test: add container network test

This commit is contained in:
Abdud Dayan Adeeb 2021-02-15 17:06:32 -05:00
parent a34de16206
commit 8279676ac5

View File

@ -11,13 +11,15 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ./ - name: Run docker action and set output for testing
uses: ./
id: run-docker id: run-docker
with: with:
image: docker:20.10.3 image: docker:20.10.3
run: | run: |
echo "::set-output name=docker-version::`echo $DOCKER_VERSION`" echo "::set-output name=docker-version::`echo $DOCKER_VERSION`"
- uses: actions/github-script@v3 - name: Test the output
uses: actions/github-script@v3
with: with:
script: | script: |
const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}'; const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}';
@ -28,18 +30,43 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: echo "some text" > someFile - name: Create File to be mounted
- uses: ./ run: echo "some text" > someFile
- name: Run docker action with mounted workspace
uses: ./
id: run-docker id: run-docker
with: with:
image: docker image: docker
options: -v ${{ github.workspace }}:/work options: -v ${{ github.workspace }}:/work
run: | run: |
echo "::set-output name=file-contents::`cat /work/someFile`" echo "::set-output name=file-contents::`cat /work/someFile`"
- uses: actions/github-script@v3 - name: Check if file contents match
uses: actions/github-script@v3
with: with:
script: | script: |
const fileContents = '${{ steps.run-docker.outputs.file-contents }}'; const fileContents = '${{ steps.run-docker.outputs.file-contents }}';
if (fileContents !== 'some text') { if (fileContents !== 'some text') {
core.setFailed(`Unable to mount workspace volume`); core.setFailed(`Unable to mount workspace volume`);
} }
container-network-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: test
POSTGRES_USER: test
POSTGRES_DB: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 5s --health-timeout 5s --health-retries 10
steps:
- uses: actions/checkout@v2
- name: Run docker action and test network connection
uses: ./
with:
image: postgres
run: >
pg_isready -d test -U test -h postgres -p ${{ job.services.postgres.ports[5432] }}
options: >
-e PGPASSWORD=test