Verify committed mocks are up to date in CI #2327
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: Test | |
| on: [pull_request] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: read | |
| container: | |
| image: ghcr.io/${{ github.repository_owner }}/stackwallet-ci:test | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| steps: | |
| - name: Prepare repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Configure app | |
| run: | | |
| cd scripts | |
| echo "yes" | ./build_app.sh -v "0.0.1" -b "1" -p "linux" -a "stack_wallet" -d -s | |
| - name: Get dependencies | |
| run: flutter pub get | |
| - name: Create git_versions.dart stubs | |
| run: | | |
| mkdir -p crypto_plugins/flutter_libepiccash/lib | |
| mkdir -p crypto_plugins/flutter_libmwc/lib | |
| cat > crypto_plugins/flutter_libepiccash/lib/git_versions.dart << 'EOF' | |
| String getPluginVersion() => "stub-for-tests"; | |
| EOF | |
| cat > crypto_plugins/flutter_libmwc/lib/git_versions.dart << 'EOF' | |
| String getPluginVersion() => "stub-for-tests"; | |
| EOF | |
| - name: Decode secrets | |
| env: | |
| CHANGE_NOW: ${{ secrets.CHANGE_NOW }} | |
| run: | | |
| if [ -n "$CHANGE_NOW" ]; then | |
| echo "$CHANGE_NOW" | base64 --decode > lib/external_api_keys.dart | |
| else | |
| cat > lib/external_api_keys.dart << 'EOF' | |
| const String kChangeNowApiKey = ""; | |
| const String kSimpleSwapApiKey = ""; | |
| const String kNanswapApiKey = ""; | |
| const String kNanoSwapRpcApiKey = ""; | |
| const String kWizSwapApiKey = ""; | |
| const kShopInBitAccessKey = ""; | |
| const kShopInBitPartnerSecret = ""; | |
| const kCakePayApiToken = ""; | |
| const kExolixApiKey = ""; | |
| EOF | |
| fi | |
| - name: Ensure app config for tests | |
| run: bash scripts/ensure_test_app_config.sh | |
| - name: Create test stubs | |
| run: bash prebuild.sh | |
| working-directory: scripts | |
| - name: Verify committed mocks are up to date | |
| run: | | |
| dart run build_runner build --delete-conflicting-outputs | |
| if ! git diff --exit-code -- '*.mocks.dart'; then | |
| echo "Committed mocks are out of date. Run 'dart run build_runner build --delete-conflicting-outputs' locally and commit the regenerated files." | |
| exit 1 | |
| fi | |
| - name: Check formatting of changed files | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE=$(git merge-base ${{ github.event.pull_request.base.sha }} HEAD) | |
| else | |
| BASE=${{ github.event.before }} | |
| fi | |
| FILES=$(git diff --name-only --diff-filter=ACM "$BASE"..HEAD -- '*.dart') | |
| if [ -z "$FILES" ]; then | |
| echo "No Dart files changed." | |
| exit 0 | |
| fi | |
| echo "Checking formatting of $(echo "$FILES" | wc -l) file(s):" | |
| echo "$FILES" | |
| dart format --output=none --set-exit-if-changed $FILES | |
| # - name: Analyze | |
| # run: flutter analyze | |
| - name: Test | |
| run: | | |
| bash scripts/ensure_test_app_config.sh | |
| test -s lib/app_config.g.dart | |
| grep -Fq "part of 'app_config.dart';" lib/app_config.g.dart | |
| flutter test --coverage | |
| - name: Upload to code coverage | |
| uses: codecov/codecov-action@v1.2.2 | |
| if: success() || failure() | |
| with: | |
| token: ${{secrets.CODECOV_TOKEN}} | |
| file: coverage/lcov.info |