Skip to content

Commit acc6969

Browse files
committed
docker tests
1 parent b1810ae commit acc6969

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

.env.sh.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export GITHUB_TOKEN="gh123abc"

.github/workflows/pr.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,25 @@ jobs:
3636
run: npm run test
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GH_TKN }}
39+
40+
# docs: https://github.com/marketplace/actions/build-and-push-docker-images
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
# docs: https://docs.docker.com/build/ci/github-actions/test-before-push/
48+
- name: Build Docker image
49+
uses: docker/build-push-action@v5
50+
with:
51+
push: false
52+
context: .
53+
load: true
54+
tags: github-graphql-client:latest
55+
56+
- name: Run Docker tests
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GH_TKN }}
59+
run: npm run docker:test
60+
continue-on-error: true

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"test": "jest",
1313
"test:index": "jest --testPathPattern=index.test.js",
1414
"test:github": "jest --testPathPattern=github.test.js",
15-
"docker:build": "docker build -t github-graphql-client -f Dockerfile ."
15+
"docker:build": "docker build -t github-graphql-client -f Dockerfile .",
16+
"docker:test": "./test.docker.sh",
17+
"docker:all": "npm run docker:build && npm run docker:test"
1618
},
1719
"keywords": [
1820
"git",

test.docker.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
source .env.sh
4+
5+
echo "************** help *****************"
6+
7+
# test handling of single parameter
8+
docker run --rm \
9+
-v ./dummy:/app/dummy \
10+
-w /app \
11+
-e GITHUB_TOKEN \
12+
-e DEBUG \
13+
github-graphql-client:latest "--help"
14+
15+
echo "************ branch arg missing *******************"
16+
17+
# test handling of multiple parameters
18+
docker run --rm \
19+
-v ./dummy:/app/dummy \
20+
-w /app \
21+
-e GITHUB_TOKEN \
22+
-e DEBUG \
23+
github-graphql-client:latest commit -o pirafrank -r 'test-repo' -c dummy/file1.txt -m 'this is a commit msg'
24+
25+
echo "************** all separated *****************"
26+
27+
# test handling of multiple parameters
28+
docker run --rm \
29+
-v ./dummy:/app/dummy \
30+
-w /app \
31+
-e GITHUB_TOKEN \
32+
-e DEBUG \
33+
github-graphql-client:latest commit -o pirafrank -r 'test-repo' -b main -c dummy/file1.txt -m onewordcommitmsg
34+
35+
echo "************** all as one arg *****************"
36+
37+
# test multiple parameters surrounded by double quotes
38+
# this is to test if the entrypoint.sh script can handle double quotes,
39+
# because GitHub Actions will pass arguments as a single string.
40+
docker run --rm \
41+
-v ./dummy:/app/dummy \
42+
-w /app \
43+
-e GITHUB_TOKEN \
44+
-e DEBUG \
45+
github-graphql-client:latest "commit -o pirafrank -r "test-repo" -b main -c dummy/file1.txt -m 'this is a commit msg'"

0 commit comments

Comments
 (0)