test-ci #4067
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: "CI and E2E Tests" | ||
on: | ||
push: | ||
branches: [dev, feature/email-templates-v2] | ||
jobs: | ||
ci: | ||
if: github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- name: Install dependencies | ||
run: npm i | ||
- name: Install CI checks | ||
run: npm ci | ||
- name: Check types | ||
run: npm run typecheck | ||
- name: Lint with Biome | ||
run: npx @biomejs/biome check src/. | ||
- name: Lint styles | ||
run: npx stylelint **/*.{scss,css} | ||
- name: Build email templates | ||
id: build-templates | ||
if: | | ||
contains(github.event.head_commit.modified, 'src/emails/') || | ||
contains(github.event.head_commit.modified, 'src/entry-email.tsx') | ||
run: | | ||
npm run build | ||
mkdir -p templates/dist | ||
# Копируем файлы с правильными именами для mailgun | ||
for src in dist/public/emails/emails/*.html; do | ||
name=$(basename "$src" .html) | ||
case $name in | ||
"email_confirmation") dst="authorizer_email_confirmation";; | ||
"password_reset") dst="authorizer_password_reset";; | ||
"first_publication") dst="email_first_publication";; | ||
"new_comment") dst="new_comment_notification";; | ||
*) continue;; | ||
esac | ||
cp "$src" "templates/dist/${dst}.html" | ||
done | ||
env: | ||
CI: true | ||
- name: Update Mailgun Templates | ||
needs: build-templates | ||
if: steps.build-templates.outputs.templates_changed == 'true' | ||
run: | | ||
for template in authorizer_email_confirmation authorizer_password_reset email_first_publication new_comment_notification; do | ||
if [[ -f "templates/dist/${template}.html" ]]; then | ||
echo "Updating $template in Mailgun..." | ||
curl -s --user "api:${{ secrets.MAILGUN_API_KEY }}" \ | ||
https://api.mailgun.net/v3/discours.io/templates \ | ||
-F template="@templates/dist/${template}.html" \ | ||
-F name="$template" | ||
fi | ||
done | ||
- name: Test production build | ||
run: npm run build | ||
e2e_tests: | ||
needs: ci | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Debug event info | ||
run: | | ||
echo "Event Name: ${{ github.event_name }}" | ||
echo "Deployment Status: ${{ github.action_status }}" | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Wait for deployment to be live | ||
run: | | ||
echo "Waiting for Vercel deployment to be live..." | ||
until curl -sSf https://testing.discours.io > /dev/null; do | ||
printf '.' | ||
sleep 10 | ||
done | ||
- name: create env file | ||
run: | | ||
touch .env | ||
echo TEST_PASSWORD=${{ github.env.TEST_PASSWORD }} >> .env | ||
- name: Install Playwright and dependencies | ||
run: npm run e2e:install | ||
- name: Run Playwright tests | ||
run: npm run e2e:tests:ci | ||
env: | ||
BASE_URL: https://testing.discours.io | ||
continue-on-error: true | ||
- name: Report test result if failed | ||
if: failure() | ||
run: echo "E2E tests failed. Please review the logs." |