Skip to content

Commit

Permalink
chore(test): test running docker after build (DIYgod#8010)
Browse files Browse the repository at this point in the history
* chore(test): test running docker after build

* add test in the same step

* add count times

* workflow typo

* add name when output

* if then

* test docker

* use id

* no tag

* what is docker id

* load single platform

* do not test multi-arch for now

* no load
  • Loading branch information
NeverBehave authored Aug 14, 2021
1 parent 9968dbf commit 47176b6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,21 @@ on:
- 'lib/**'
- 'Dockerfile'
- 'package.json'
push:
branches: '*'
paths:
- '.github/workflows/**'
- 'lib/**'
- 'Dockerfile'
- 'package.json'

# Please, always create a pull request instead of push to master.
jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Build dockerfile (without push)
run: |
docker buildx build \
--platform=linux/amd64,linux/arm/v7,linux/arm64 \
--output "type=image,push=false" \
--file ./Dockerfile .
- name: Build dockerfile and Run (without push)
run: |
docker build \
--tag rsshub:latest \
--file ./Dockerfile .
chmod +x scripts/docker/test-docker.sh
scripts/docker/test-docker.sh
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"string-width": "4.2.2",
"supertest": "6.1.3",
"vuepress": "1.8.2",
"yorkie": "2.0.0"
"yorkie": "2.0.0",
"fs-extra": "^8.1.0"
},
"dependencies": {
"@koa/router": "10.0.0",
Expand Down
31 changes: 31 additions & 0 deletions scripts/docker/test-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

MAX_RETRIES=60
# Try running the docker and get the output
# then try getting homepage in 3 mins

docker run -d -p 1200:1200 rsshub:latest

if [[ $? -ne 0 ]]
then
echo "failed to run docker"
exit 1
fi

RETRY=1
curl -m 10 localhost:1200
while [[ $? -ne 0 ]] && [[ $RETRY -lt $MAX_RETRIES ]]; do
sleep 5
((RETRY++))
echo "RETRY: ${RETRY}"
curl -m 10 localhost:1200
done

if [[ $RETRY -gt $MAX_RETRIES ]]
then
echo "Unable to run, aborted"
exit 1
else
echo "Successfully acquire homepage, passing"
exit 0
fi

0 comments on commit 47176b6

Please sign in to comment.