Skip to content

Commit

Permalink
Merge pull request #132 from WyriHaximus/add-unit-tests
Browse files Browse the repository at this point in the history
Add unit tests
  • Loading branch information
WyriHaximus committed May 22, 2023
2 parents 47ee55f + 30db90d commit d5385d1
Show file tree
Hide file tree
Showing 5 changed files with 544 additions and 502 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ on:
- master
pull_request:
jobs:
test-docker-image:
runs-on: ubuntu-latest
needs: build-docker-image
steps:
- uses: actions/checkout@v1
- run: sed -i "s/master/sha-${GITHUB_SHA}/g" Dockerfile
- name: 'Wait for status checks'
id: waitforstatuschecks
uses: ./
with:
ignoreActions: "test-docker-image,Create Release,Wait for status checks"
checkInterval: 1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- run: |
echo "${{ steps.waitforstatuschecks.outputs.status }}"
exit 78
if: steps.waitforstatuschecks.outputs.status != 'success'
composer-install:
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -97,7 +79,6 @@ jobs:
needs:
- generate-ref
- lint-dockerfile
- qa
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -125,7 +106,26 @@ jobs:
--password-stdin
- 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
- run: docker pull $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]')
- 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:]')
# - 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:]')
- run: |
printf "FROM %s" $(echo "ghcr.io/${GITHUB_REPOSITORY}:sha-${GITHUB_SHA}" | tr '[:upper:]' '[:lower:]') >> Dockerfile.tag
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:]') .
test-docker-image:
runs-on: ubuntu-latest
needs: build-docker-image
steps:
- uses: actions/checkout@v1
- run: sed -i "s/master/sha-${GITHUB_SHA}/g" Dockerfile
- name: 'Wait for status checks'
id: waitforstatuschecks
uses: ./
with:
ignoreActions: "test-docker-image,Create Release,Wait for status checks"
checkInterval: 1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: "Assert Output: status is successful"
uses: nick-fields/assert-action@v1
with:
expected: success
actual: ${{ steps.waitforstatuschecks.outputs.status }}
10 changes: 5 additions & 5 deletions Dockerfile-build
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# syntax=docker/dockerfile:experimental
FROM wyrihaximusnet/php:7.4-nts-alpine-dev-root AS install-dependencies
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN mkdir /workdir
COPY ./composer.* /workdir/
WORKDIR /workdir
RUN composer install --ansi --no-progress --no-interaction --prefer-dist
COPY ./src /workdir/src
COPY ./composer.* ./wait.php /workdir/
RUN composer install --ansi --no-progress --no-interaction --prefer-dist --no-dev

## Compile runtime image
FROM wyrihaximusnet/php:7.4-nts-alpine-root AS runtime
RUN mkdir /workdir
WORKDIR /workdir
COPY ./src /workdir/src
COPY ./composer.* ./wait.php /workdir/
COPY --from=install-dependencies /workdir/vendor/ /workdir/vendor/
COPY --from=install-dependencies /workdir/ /workdir/
RUN ls -lasth ./
ENTRYPOINT ["php", "/workdir/wait.php"]
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
}
},
"scripts": {
"post-install-cmd": [
"composer normalize"
],
"post-update-cmd": [
"composer normalize"
]
Expand Down
Loading

0 comments on commit d5385d1

Please sign in to comment.