Add model property to TokenUsage for cost calculation #3272
This file contains hidden or 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: Tests | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - 'src/*/doc/**' | |
| - 'src/**/*.md' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| REQUIRED_PHP_EXTENSIONS: 'mongodb, redis' | |
| jobs: | |
| # =========================================== | |
| # Build Matrix | |
| # =========================================== | |
| matrix: | |
| name: Matrix | |
| uses: ./.github/workflows/build-matrix.yaml | |
| # =========================================== | |
| # Unit Tests | |
| # =========================================== | |
| packages: | |
| name: Unit / ${{ matrix.package.type }} / ${{ matrix.package.name }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }}${{ matrix.symfony-version && format(' / Symfony {0}', matrix.symfony-version) || '' }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package: ${{ fromJson(needs.matrix.outputs.packages) }} | |
| php-version: ['8.2', '8.5'] | |
| dependency-version: [''] | |
| symfony-version: [''] | |
| include: ${{ fromJson(needs.matrix.outputs.packages-include) }} | |
| env: | |
| SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=7.4' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| # deptrac does not support Symfony 5.4 | |
| - name: Remove deptrac for unsupported Symfony versions | |
| if: startsWith(matrix.symfony-version, '5.4') | |
| run: composer remove --dev deptrac/deptrac --no-update | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Clean vendor folder | |
| run: rm -rf vendor | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: src/${{ matrix.package.path }} | |
| dependency-versions: ${{ matrix.dependency-version || 'highest' }} | |
| - name: Run PHPUnit | |
| run: cd src/${{ matrix.package.path }} && vendor/bin/phpunit | |
| store-bridges: | |
| name: Unit / Store / ${{ matrix.bridge.bridge }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.matrix.outputs.store-bridges-include) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Isolate Bridge | |
| uses: ./.github/actions/isolate-bridge | |
| with: | |
| component: ${{ matrix.bridge.component }} | |
| bridge: ${{ matrix.bridge.bridge }} | |
| target: tmp | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: tmp/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: Run PHPUnit | |
| run: cd tmp/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpunit --exclude-group integration | |
| store-bridges-integration: | |
| name: Integration / Store / ${{ matrix.bridge }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| bridge: ${{ fromJson(needs.matrix.outputs.store-bridges-integration) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Isolate Bridge | |
| uses: ./.github/actions/isolate-bridge | |
| with: | |
| component: store | |
| bridge: ${{ matrix.bridge }} | |
| target: tmp | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: tmp/store/src/Bridge/${{ matrix.bridge }} | |
| - name: Start Docker services | |
| working-directory: tmp/store/src/Bridge/${{ matrix.bridge }} | |
| run: docker compose up -d --wait || true | |
| - name: Wait for services to be ready | |
| run: sleep 15 | |
| - name: Run integration tests | |
| run: cd tmp/store/src/Bridge/${{ matrix.bridge }} && vendor/bin/phpunit --group integration | |
| - name: Stop Docker services | |
| working-directory: tmp/store/src/Bridge/${{ matrix.bridge }} | |
| run: docker compose down || true | |
| message-store-bridges: | |
| name: Unit / Message Store / ${{ matrix.bridge.bridge }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.matrix.outputs.message-store-bridges-include) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Isolate Bridge | |
| uses: ./.github/actions/isolate-bridge | |
| with: | |
| component: ${{ matrix.bridge.component }} | |
| bridge: ${{ matrix.bridge.bridge }} | |
| target: tmp | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: tmp/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: Run PHPUnit | |
| run: cd tmp/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpunit | |
| tool-bridges: | |
| name: Unit / Tool / ${{ matrix.bridge.bridge }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.matrix.outputs.tool-bridges-include) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Isolate Bridge | |
| uses: ./.github/actions/isolate-bridge | |
| with: | |
| component: ${{ matrix.bridge.component }} | |
| bridge: ${{ matrix.bridge.bridge }} | |
| target: tmp | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: tmp/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: Run PHPUnit | |
| run: cd tmp/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpunit | |
| platform-bridges: | |
| name: Unit / Platform / ${{ matrix.bridge.bridge }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.matrix.outputs.platform-bridges-include) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Isolate Bridge | |
| uses: ./.github/actions/isolate-bridge | |
| with: | |
| component: platform | |
| bridge: ${{ matrix.bridge.bridge }} | |
| target: tmp | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: tmp/platform/src/Bridge/${{ matrix.bridge.bridge }} | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: Run PHPUnit | |
| run: cd tmp/platform/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpunit | |
| mate-bridges: | |
| name: Unit / Mate / ${{ matrix.bridge.bridge }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }} | |
| needs: matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.matrix.outputs.mate-bridges-include) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }} | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build packages | |
| run: php .github/build-packages.php | |
| - name: Isolate Bridge | |
| uses: ./.github/actions/isolate-bridge | |
| with: | |
| component: mate | |
| bridge: ${{ matrix.bridge.bridge }} | |
| target: tmp | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: tmp/mate/src/Bridge/${{ matrix.bridge.bridge }} | |
| dependency-versions: ${{ matrix.dependency-version }} | |
| - name: Run PHPUnit | |
| run: cd tmp/mate/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpunit | |
| demo: | |
| name: Integration / Demo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| tools: flex | |
| extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| - name: Install demo dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| composer-options: "--no-scripts" | |
| working-directory: demo | |
| - name: Link local packages | |
| working-directory: demo | |
| run: ../link | |
| - run: composer run-script auto-scripts --no-interaction | |
| working-directory: demo | |
| - run: bin/console lint:container | |
| working-directory: demo | |
| - name: Run demo tests | |
| working-directory: demo | |
| run: vendor/bin/phpunit | |
| demo-no-dev: | |
| name: Integration / Demo (no-dev) | |
| needs: demo | |
| runs-on: ubuntu-latest | |
| env: | |
| APP_ENV: prod | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| tools: flex | |
| extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| - name: Install demo dependencies (no-dev) | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| composer-options: "--no-scripts --no-dev" | |
| working-directory: demo | |
| - name: Link local packages | |
| working-directory: demo | |
| run: ../link | |
| - run: composer run-script auto-scripts --no-interaction | |
| working-directory: demo | |
| - run: bin/console lint:container | |
| working-directory: demo | |
| - run: bin/console cache:clear | |
| working-directory: demo | |
| examples: | |
| name: Integration / Examples / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }}${{ matrix.symfony-version && format(' / Symfony {0}', matrix.symfony-version) || '' }} | |
| needs: demo | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: ['8.2', '8.5'] | |
| dependency-version: [''] | |
| symfony-version: [''] | |
| include: | |
| # lowest deps | |
| - php-version: '8.2' | |
| dependency-version: 'lowest' | |
| # LTS version of Symfony | |
| - php-version: '8.2' | |
| symfony-version: '7.4.*' | |
| env: | |
| SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=7.4' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Up the examples services | |
| working-directory: examples | |
| run: docker compose up -d meilisearch mongodb pogocache redis surrealdb | |
| - name: Configure environment | |
| run: | | |
| echo COLUMNS=120 >> $GITHUB_ENV | |
| echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest --prefer-stable' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV | |
| echo PHPUNIT='vendor/bin/phpunit' >> $GITHUB_ENV | |
| [ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak | |
| PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "examples" | sort | tr '\n' ' ') | |
| echo "Packages: $PACKAGES" | |
| echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: flex | |
| extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" | |
| # deptrac does not support Symfony 5.4, 6.4, and 8 yet | |
| - name: Remove deptrac for unsupported Symfony versions | |
| if: startsWith(matrix.symfony-version, '5.4') | |
| run: composer remove --dev deptrac/deptrac --no-update | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v4 | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| - name: Install examples dependencies | |
| uses: ramsey/composer-install@v4 | |
| with: | |
| working-directory: examples | |
| - name: Link local components to examples | |
| run: ./link examples | |
| - name: Run commands examples | |
| working-directory: examples | |
| run: | | |
| php commands/stores.php | |
| php commands/message-stores.php |