Skip to content

test: add component tests for ConnectorFields #4377

test: add component tests for ConnectorFields

test: add component tests for ConnectorFields #4377

# This workflow runs the tests in the test projects to make sure the generator works as a library where it is a Node dependency along with the template.
name: Test using test project
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
jobs:
changes:
runs-on: ubuntu-latest
outputs:
should_test: ${{ steps.should_run.outputs.shouldrun }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 https://github.com/actions/checkout/releases/tag/v3
- name: Checks paths-filter
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 https://github.com/dorny/paths-filter/releases/tag/v4.0.1
id: filter
with:
predicate-quantifier: 'every'
filters: |
modified_files:
- '!**/*.md'
- '!.all-contributorsrc'
- '!.coderabbit.yaml'
- '!CODEOWNERS'
- '!LICENSE'
- '!NOTICE'
- name: Determine if tests should run
id: should_run
if: >
steps.filter.outputs.modified_files == 'true' &&
!github.event.pull_request.draft && !(
(github.actor == 'asyncapi-bot' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'asyncapi-bot-eve' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'allcontributors[bot]' &&
startsWith(github.event.pull_request.title, 'docs: add')
)
)
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
shell: bash
#this test job is responsible for running dedicated complex integration tests for the generator
test:
needs: changes
name: Test generator as dependency with Node 24
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
- name: Log should_test value across jobs #it has to stay here for some time for debugging
run: |
echo "should_test value: ${{ needs.changes.outputs.should_test }}"
- if: needs.changes.outputs.should_test == 'true'
name: Run test
run: NODE_VERSION=24 docker compose up --abort-on-container-exit --force-recreate
working-directory: ./apps/generator/test/test-project
#this test job runs acceptance tests that use microcks and check generated code against the asyncapi contract
acceptance:
needs: changes
name: Acceptance tests (${{ matrix.language }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [js, py, java]
steps:
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 https://github.com/actions/checkout/releases/tag/v3
- name: Log should_test value across jobs #it has to stay here for some time for debugging
run: |
echo "should_test value: ${{ needs.changes.outputs.should_test }}"
- name: Check package-lock version
if: needs.changes.outputs.should_test == 'true'
# This workflow is from our own org repo and safe to reference by 'master'.
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
id: lockversion
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Use Node.js
if: needs.changes.outputs.should_test == 'true'
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "${{ steps.lockversion.outputs.version }}"
- name: Install dependencies
if: needs.changes.outputs.should_test == 'true'
run: npm ci
- name: Generate clients
if: needs.changes.outputs.should_test == 'true'
run: npm run packages:test
- name: Bundle AsyncAPI spec
if: needs.changes.outputs.should_test == 'true'
uses: asyncapi/cli@1b8a4d320bb0e58d19d250dfe69e630df0cac9cd
with:
custom_command: bundle packages/templates/clients/websocket/test/__fixtures__/asyncapi-hoppscotch-server.yml --output packages/templates/clients/websocket/test/__fixtures__/bundled.yml
- name: Setup microcks environment
if: needs.changes.outputs.should_test == 'true'
run: docker compose -f ./microcks-setup/microcks-podman.yml --profile ci up -d --force-recreate
working-directory: ./packages/templates/clients/websocket/test
- name: Run ${{ matrix.language }} acceptance tests
if: needs.changes.outputs.should_test == 'true'
run: |
docker compose -f ./microcks-setup/microcks-podman.yml \
--profile test-${{ matrix.language }} \
up --abort-on-container-exit --force-recreate
working-directory: ./packages/templates/clients/websocket/test