Add msmtp test automation #58
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- .github/workflows/docker-test.yml | |
- "*.dockerfile" | |
- cypress/** | |
- cypress.config.ts | |
- files/** | |
- package.json | |
- package-lock.json | |
pull_request: | |
paths: | |
- .github/workflows/docker-test.yml | |
- "*.dockerfile" | |
- cypress/** | |
- cypress.config.ts | |
- files/** | |
- package.json | |
- package-lock.json | |
jobs: | |
test: | |
name: Test Docker image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
dockerfile: [apache, apache-php8.0, nginx, nginx-php8.0] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
- name: Install Cypress dependencies | |
run: npm ci | |
- name: Build Baikal image | |
id: build-baikal-image | |
run: echo "IMAGE_ID=$(docker build -qf ${{ matrix.dockerfile }}.dockerfile .)" >> "$GITHUB_OUTPUT" | |
- name: Start Baikal container | |
run: docker run --rm -dp 80:80 --name ${{ matrix.dockerfile }} ${{ steps.build-baikal-image.outputs.IMAGE_ID }} | |
- name: Run Cypress tests | |
run: npm run test | |
- name: Stop Baikal container | |
run: docker stop ${{ matrix.dockerfile }} | |
- name: Start Baikal container with MSMTP configuration | |
env: | |
MSMTPRC: | | |
# Set default values for all following accounts. | |
defaults | |
auth on | |
tls on | |
tls_trust_file /etc/ssl/certs/ca-certificates.crt | |
logfile /dev/stdout | |
# Confiure mailtrap | |
account mailtrap | |
host sandbox.smtp.mailtrap.io | |
port 25 | |
tls_starttls on | |
from [email protected] | |
user ${{ secrets.MAILTRAP_USER }} | |
password ${{ secrets.MAILTRAP_PASSWORD }} | |
# Set a default account | |
account default: mailtrap | |
run: | | |
docker run --rm -dp 80:80 -e MSMTPRC="$MSMTPRC" --name ${{ matrix.dockerfile }}-msmtp ${{ steps.build-baikal-image.outputs.IMAGE_ID }} | |
docker cp ${{ github.workspace }}/cypress/fixtures/mail-test.php ${{ matrix.dockerfile }}-msmtp:/var/www/baikal/html/ | |
- name: Run Cypress tests | |
run: npm run test -- --env MAILTRAP_TOKEN=${{ secrets.MAILTRAP_TOKEN }},MAILTRAP_ACCOUNTID=${{ secrets.MAILTRAP_ACCOUNTID }},MAILTRAP_INBOXID=${{ secrets.MAILTRAP_INBOXID }},MAILTRAP_SUBJECT='${{ github.sha }} - ${{ github.job }} attempt ${{ github.run_attempt }}' --config excludeSpecPattern='[]',screenshotsFolder=cypress/screenshots/mailtrap | |
- name: Archive test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cypress-results-${{ matrix.dockerfile }} | |
path: cypress/screenshots |