Skip to content

Merge pull request #6571 from FlowFuse/ff-assistant #8259

Merge pull request #6571 from FlowFuse/ff-assistant

Merge pull request #6571 from FlowFuse/ff-assistant #8259

Workflow file for this run

name: Tests
on:
push:
branches:
- main
- maintenance
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-changes:
name: Verify changes
runs-on: ubuntu-latest
outputs:
run_backend_tests: ${{ steps.changed-files.outputs.backend_changed }}
run_postgres_tests: ${{ steps.changed-files.outputs.postgres_changed }}
run_ui_tests: ${{ steps.changed-files.outputs.ui_changed }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Find changed files
id: changed-files
run: |
./.github/scripts/detect_changed_files.sh
backend-tests:
if: ${{ needs.check-changes.outputs.run_backend_tests == 'true' }}
name: Backend tests
needs: check-changes
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm ci
- name: Build the forge
run: npm run build
- name: Run forge unit tests
run: npm run cover:unit:forge
- name: Run forge system tests
run: npm run cover:system
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: backend
postgres-tests:
if: ${{ needs.check-changes.outputs.run_postgres_tests == 'true' }}
name: Postgres tests
needs: check-changes
runs-on: ubuntu-latest
timeout-minutes: 45
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: secret
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
-m 3GB
ports:
- 5432:5432
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm ci
- name: Build the forge
run: npm run build
- name: Test the forge (with PostgreSQL)
env:
FF_TEST_DB_POSTGRES: true
FF_TEST_DB_POSTGRES_HOST: localhost
FF_TEST_DB_POSTGRES_PORT: 5432
FF_TEST_DB_POSTGRES_USER: postgres
FF_TEST_DB_POSTGRES_PASSWORD: secret
FF_TEST_DB_POSTGRES_DATABASE: flowforge
NODE_OPTIONS: "--max-old-space-size=6144"
run: npm run test
ui-unit-tests:
if: ${{ needs.check-changes.outputs.run_ui_tests == 'true' }}
name: UI unit tests
needs: check-changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Dependencies
run: npm ci
- name: Run Linting Tests
run: npm run lint
- name: Run UI Unit Tests
run: npm run test:unit:frontend
ui-os-tests:
if: ${{ needs.check-changes.outputs.run_ui_tests == 'true' }}
name: UI OS tests
needs: check-changes
runs-on: ubuntu-latest
services:
email-service:
image: axllent/mailpit
ports:
- 8025:8025
- 1025:1025
options: >-
--env MP_MAX_MESSAGES=5000
--env MP_SMTP_AUTH_ACCEPT_ANY=1
--env MP_SMTP_AUTH_ALLOW_INSECURE=1
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Dependencies
run: npm ci
- name: Run UI E2E (Cypress) Tests - OS
uses: cypress-io/github-action@8a35f965fbd13e3b18d9fb3bdc5f50ae2f4a5e76 # v7.1.0
with:
install: false
config-file: config/cypress-os.config.js
build: npm run build
start: npm run cy:web-server:os
env:
NO_SMTP_SERVER: 'true'
SMTP_HOST: 'localhost'
SMTP_PORT: '1025'
SMTP_WEB_PORT: '8025'
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure()
with:
name: os-cypress-output-${{ github.run_id }}-${{ github.run_number }}
path: |
test/e2e/frontend/cypress/screenshots
test/e2e/frontend/cypress/videos
ui-ee-tests:
if: ${{ needs.check-changes.outputs.run_ui_tests == 'true' }}
name: UI EE tests
needs: check-changes
runs-on: ubuntu-latest
services:
email-service:
image: axllent/mailpit
ports:
- 8025:8025
- 1025:1025
options: >-
--env MP_MAX_MESSAGES=5000
--env MP_SMTP_AUTH_ACCEPT_ANY=1
--env MP_SMTP_AUTH_ALLOW_INSECURE=1
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Dependencies
run: npm ci
- name: Run UI E2E (Cypress) Tests - EE
uses: cypress-io/github-action@8a35f965fbd13e3b18d9fb3bdc5f50ae2f4a5e76 # v7.1.0
with:
install: false
config-file: config/cypress-ee.config.js
build: npm run build
start: npm run cy:web-server:ee
env:
NO_SMTP_SERVER: 'true'
SMTP_HOST: 'localhost'
SMTP_PORT: '1025'
SMTP_WEB_PORT: '8025'
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure()
with:
name: ee-cypress-output-${{ github.run_id }}-${{ github.run_number }}
path: |
test/e2e/frontend/cypress/screenshots
test/e2e/frontend/cypress/videos
notify-slack:
name: Notify on failure
needs: [backend-tests, postgres-tests, ui-os-tests, ui-ee-tests]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Map users
id: map-actor-to-slack
uses: icalia-actions/map-github-actor@e568d1dd6023e406a1db36db4e1e0b92d9dd7824 # v0.0.2
with:
actor-map: ${{ vars.SLACK_GITHUB_USERS_MAP }}
default-mapping: C067BD0377F
- name: Generate payload variables
run: |
if [[ "${{ github.ref_name }}" == 'main' || "${{ github.ref_name }}" == 'maintenance' ]] ; then
echo "HEADER_MESSAGE=Tests failed against ${{ github.ref_name }} branch" >> $GITHUB_ENV
echo "SUMMARY_ICON=no_entry" >> $GITHUB_ENV
echo "SUMMARY_MESSAGE= Deployment to FFC environments will not happen until this issue is resolved." >> $GITHUB_ENV
echo "LAST_COMMIT_SHA=${{ github.sha}}" >> $GITHUB_ENV
echo "PR_LINK=*Branch:* ${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "HEADER_MESSAGE=Tests failed against ${{ github.event.number }} pull request" >> $GITHUB_ENV
echo "SUMMARY_ICON=warning" >> $GITHUB_ENV
echo "SUMMARY_MESSAGE= Please resolve the problem before merging your changes into the main branch." >> $GITHUB_ENV
echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "PR_LINK=*Pull request:* <https://github.com/FlowFuse/flowfuse/pull/${{ github.event.pull_request.number }}|${{ github.event.pull_request.number }}>" >> $GITHUB_ENV
fi
- name: Send notification
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.SLACK_GHBOT_TOKEN }}
payload: |
{
"channel": "C067BD0377F",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: ${{ env.HEADER_MESSAGE }}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "${{ env.SUMMARY_ICON }}"
},
{
"type": "text",
"text": " ${{ env.SUMMARY_MESSAGE }}",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Author:* <@${{ steps.map-actor-to-slack.outputs.actor-mapping }}>"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View failed workflow>"
},
{
"type": "mrkdwn",
"text": "*Last commit:* <${{ github.server_url }}/${{ github.repository }}/commit/${{ env.LAST_COMMIT_SHA }}|${{ env.LAST_COMMIT_SHA }}>"
},
{
"type": "mrkdwn",
"text": "${{ env.PR_LINK }}"
}
]
}
]
}