This repository has been archived on 2024-09-20. You can view files and clone it, but cannot push or open issues or pull requests.
docker-run-action/.github/workflows/tests.yml

73 lines
2.1 KiB
YAML
Raw Normal View History

2021-02-15 21:58:29 +01:00
name: Docker Run Action Tests
on:
push:
branches:
- '**'
2021-02-15 21:58:29 +01:00
pull_request:
jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
2021-02-15 23:06:32 +01:00
- name: Run docker action and set output for testing
uses: ./
2021-02-15 22:28:52 +01:00
id: run-docker
2021-02-15 21:58:29 +01:00
with:
image: docker:20.10.3
run: |
2021-02-15 22:28:52 +01:00
echo "::set-output name=docker-version::`echo $DOCKER_VERSION`"
2021-02-15 23:06:32 +01:00
- name: Test the output
uses: actions/github-script@v3
2021-02-15 21:58:29 +01:00
with:
script: |
2021-02-15 22:28:52 +01:00
const dockerVersion = '${{ steps.run-docker.outputs.docker-version }}';
2021-02-15 22:52:12 +01:00
if (dockerVersion !== '20.10.3') {
2021-02-15 22:28:52 +01:00
core.setFailed(`Smoke Test Failed`);
}
2021-02-15 22:52:12 +01:00
volume-mount-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
2021-02-15 23:06:32 +01:00
- name: Create File to be mounted
run: echo "some text" > someFile
- name: Run docker action with mounted workspace
uses: ./
2021-02-15 22:52:12 +01:00
id: run-docker
with:
image: docker
options: -v ${{ github.workspace }}:/work
run: |
echo "::set-output name=file-contents::`cat /work/someFile`"
2021-02-15 23:06:32 +01:00
- name: Check if file contents match
uses: actions/github-script@v3
2021-02-15 22:52:12 +01:00
with:
script: |
const fileContents = '${{ steps.run-docker.outputs.file-contents }}';
if (fileContents !== 'some text') {
core.setFailed(`Unable to mount workspace volume`);
}
2021-02-15 23:06:32 +01:00
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