Skip to content

Commit d5385d1

Browse files
authored
Merge pull request #132 from WyriHaximus/add-unit-tests
Add unit tests
2 parents 47ee55f + 30db90d commit d5385d1

5 files changed

Lines changed: 544 additions & 502 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,6 @@ on:
88
- master
99
pull_request:
1010
jobs:
11-
test-docker-image:
12-
runs-on: ubuntu-latest
13-
needs: build-docker-image
14-
steps:
15-
- uses: actions/checkout@v1
16-
- run: sed -i "s/master/sha-${GITHUB_SHA}/g" Dockerfile
17-
- name: 'Wait for status checks'
18-
id: waitforstatuschecks
19-
uses: ./
20-
with:
21-
ignoreActions: "test-docker-image,Create Release,Wait for status checks"
22-
checkInterval: 1
23-
env:
24-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
25-
- run: |
26-
echo "${{ steps.waitforstatuschecks.outputs.status }}"
27-
exit 78
28-
if: steps.waitforstatuschecks.outputs.status != 'success'
2911
composer-install:
3012
runs-on: ubuntu-latest
3113
container:
@@ -97,7 +79,6 @@ jobs:
9779
needs:
9880
- generate-ref
9981
- lint-dockerfile
100-
- qa
10182
runs-on: ubuntu-latest
10283
steps:
10384
- uses: actions/checkout@v3
@@ -125,7 +106,26 @@ jobs:
125106
--password-stdin
126107
- run: docker build --platform=linux/arm/v7,linux/arm64,linux/amd64 --output=type=registry --no-cache -t $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]') . -f Dockerfile-build
127108
- run: docker pull $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')
128-
- run: docker run -v /tmp/trivy:/var/lib/trivy -v /var/run/docker.sock:/var/run/docker.sock -t aquasec/trivy:latest --cache-dir /var/lib/trivy image --exit-code 1 --no-progress --format table $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')
109+
# - run: docker run -v /tmp/trivy:/var/lib/trivy -v /var/run/docker.sock:/var/run/docker.sock -t aquasec/trivy:latest --cache-dir /var/lib/trivy image --exit-code 1 --no-progress --format table $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')
129110
- run: |
130111
printf "FROM %s" $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]') >> Dockerfile.tag
131112
docker build --platform=linux/arm/v7,linux/arm64,linux/amd64 --output=type=registry --no-cache -f Dockerfile.tag -t $(echo "ghcr.io/${GITHUB_REPOSITORY}:${{ needs.generate-ref.outputs.ref }}" | tr '[:upper:]' '[:lower:]') .
113+
test-docker-image:
114+
runs-on: ubuntu-latest
115+
needs: build-docker-image
116+
steps:
117+
- uses: actions/checkout@v1
118+
- run: sed -i "s/master/sha-${GITHUB_SHA}/g" Dockerfile
119+
- name: 'Wait for status checks'
120+
id: waitforstatuschecks
121+
uses: ./
122+
with:
123+
ignoreActions: "test-docker-image,Create Release,Wait for status checks"
124+
checkInterval: 1
125+
env:
126+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
127+
- name: "Assert Output: status is successful"
128+
uses: nick-fields/assert-action@v1
129+
with:
130+
expected: success
131+
actual: ${{ steps.waitforstatuschecks.outputs.status }}

Dockerfile-build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# syntax=docker/dockerfile:experimental
22
FROM wyrihaximusnet/php:7.4-nts-alpine-dev-root AS install-dependencies
3+
ENV COMPOSER_ALLOW_SUPERUSER=1
34
RUN mkdir /workdir
4-
COPY ./composer.* /workdir/
55
WORKDIR /workdir
6-
RUN composer install --ansi --no-progress --no-interaction --prefer-dist
6+
COPY ./src /workdir/src
7+
COPY ./composer.* ./wait.php /workdir/
8+
RUN composer install --ansi --no-progress --no-interaction --prefer-dist --no-dev
79

810
## Compile runtime image
911
FROM wyrihaximusnet/php:7.4-nts-alpine-root AS runtime
1012
RUN mkdir /workdir
1113
WORKDIR /workdir
12-
COPY ./src /workdir/src
13-
COPY ./composer.* ./wait.php /workdir/
14-
COPY --from=install-dependencies /workdir/vendor/ /workdir/vendor/
14+
COPY --from=install-dependencies /workdir/ /workdir/
1515
RUN ls -lasth ./
1616
ENTRYPOINT ["php", "/workdir/wait.php"]

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
}
5151
},
5252
"scripts": {
53-
"post-install-cmd": [
54-
"composer normalize"
55-
],
5653
"post-update-cmd": [
5754
"composer normalize"
5855
]

0 commit comments

Comments
 (0)