Skip to content

Commit

Permalink
feat: don't run against docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshack committed Jan 4, 2024
1 parent bc05ab1 commit e23b774
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 43 deletions.
9 changes: 7 additions & 2 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM mdshack/php:8.3-fpm-alpine-caddy

ARG CI=false

ENV XDG_CONFIG_HOME /config
ENV XDG_DATA_HOME /data

Expand Down Expand Up @@ -33,13 +35,16 @@ RUN npm install --omit optional
# Copy Application
COPY --chown=www-data . /app

RUN composer install --no-interaction --no-dev --optimize-autoloader
RUN if [[ $CI != *"true"* ]]; \
then composer install --no-interaction --optimize-autoloader; \
else composer install --no-interaction --optimize-autoloader --no-dev; \
fi

# Build Frontend
RUN npm run build

# Cleanup
RUN rm -rf /app/node_modules /usr/local/bin/composer /usr/local/bin/npm /usr/local/bin/node /usr/local/lib/node_modules
RUN if [[ $CI != *"true"* ]] ; then rm -rf /app/node_modules /usr/local/bin/composer /usr/local/bin/npm /usr/local/bin/node /usr/local/lib/node_modules ; fi

COPY --chown=www-data ./.docker/Caddyfile /etc/caddy/Caddyfile
COPY --chown=www-data ./.docker/init/* /docker-init/
Expand Down
65 changes: 24 additions & 41 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,50 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup PHP with fail-fast
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer

- name: Login to Docker Hub
uses: docker/login-action@v3
- uses: actions/setup-node@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
node-version: 'lts/*'

- run: mkdir -p ${{ runner.temp }}/docker
- run: composer install --no-interaction

- name: Build
uses: docker/build-push-action@v5
with:
tags: mdshack/shotshare:ci
cache-from: type=registry,ref=mdshack/shotshare:latest
file: ./.docker/Dockerfile
outputs: type=docker,dest=${{ runner.temp }}/docker/image.tar
- run: |
npm ci
npm run build
- name: Upload docker image
- name: Upload workspace
uses: actions/upload-artifact@v4
with:
name: docker-image
path: ${{ runner.temp }}/docker
name: workspace
path: ${{ github.workspace }}

unit-tests:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download docker image
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: docker-image
path: ${{ runner.temp }}/docker
name: workspace
path: ${{ github.workspace }}

- name: Load docker image
run: docker load --input ${{ runner.temp }}/docker/image.tar

- uses: addnab/docker-run-action@v3
with:
image: mdshack/shotshare:ci
run: /app/vendor/bin/pest
- name: Run unit tests
run: ${{ github.workspace }}/vendor/bin/pest

lint:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download docker image
- name: Download workspace
uses: actions/download-artifact@v4
with:
name: docker-image
path: ${{ runner.temp }}/docker

- name: Load docker image
run: docker load --input ${{ runner.temp }}/docker/image.tar

- uses: addnab/docker-run-action@v3
with:
image: mdshack/shotshare:ci
run: /app/vendor/bin/pint --test
name: workspace
path: ${{ github.workspace }}

# static-analysis:
# runs-on: ubuntu-latest
# steps:
- name: Run unit tests
run: ${{ github.workspace }}/vendor/bin/pint --test

0 comments on commit e23b774

Please sign in to comment.