From 0165f7f47986ae3194d2fdf6d9b08cf90903e06c Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Wed, 27 Mar 2024 11:16:01 -0700 Subject: [PATCH] Test --- .github/workflows/build.yml | 69 ++++++++++++++++ .github/workflows/dart_ci.yml | 130 +++++++++++++++++-------------- .github/workflows/dart_tests.yml | 19 +++++ .github/workflows/install.yml | 52 +++++++++++++ 4 files changed, 213 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/dart_tests.yml create mode 100644 .github/workflows/install.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..960a2ec351 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,69 @@ +name: setup + +on: + workflow_call: + inputs: + sdk: + required: true + +permissions: + contents: read + id-token: write + issues: write + pull-requests: write + +jobs: + install: + uses: ./install.yml + with: + sdk: ${{ inputs.sdk }} + secrets: inherit + + build: + needs: [install] + runs-on: ubuntu-latest + steps: + # Analyze before generated files are created to verify that component boilerplate analysis is "clean" without the need for building + - name: Analyze source (pre-build) + id: analyze-prebuild + run: | + # Analyze lib to ensure public APIs don't depend on build-to-cache files, + # which could cause analysis issues for consumers who haven't run a build yet. + dart analyze lib + dart analyze example/boilerplate_versions + + - name: Restore pub cache + id: cache-restore + uses: actions/cache/restore@v4 + with: + path: .dart_tool + key: ${{ needs.install.outputs.hash }} + + - name: Precompile DDC + id: precompile + timeout-minutes: 6 + if: steps.cache-restore.outputs.cache-hit != 'true' + run: dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled + + - name: Save pub cache + id: cache-save + uses: actions/cache/save@v4 + with: + path: .dart_tool + key: ${{ needs.install.outputs.hash }} + + - name: Verify that generated files are up-to-date + if: steps.precompile.outcome == 'success' || steps.precompile.outcome == 'skipped' + run: | + if [ ${{ inputs.sdk }} = '2.18.7' ]; then + git diff --exit-code + else + # Don't check these generated files for other SDKs, since they may generate differently + # due to different resolved dependencies. + git diff --exit-code -- ":(exclude)test/mockito.mocks.dart" ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart" + fi + + # Analyze again after generated files are created to verify that those generated classes don't cause analysis errors + - name: Analyze source (post-build) + if: steps.precompile.outcome == 'success' || steps.precompile.outcome == 'skipped' + run: dart analyze diff --git a/.github/workflows/dart_ci.yml b/.github/workflows/dart_ci.yml index 9cc4b1f88d..8f0ceeeef8 100644 --- a/.github/workflows/dart_ci.yml +++ b/.github/workflows/dart_ci.yml @@ -10,7 +10,12 @@ on: - '**' jobs: - build: +# setup: +# uses: ./build.yml +# sdk: ${{ steps.test.matrix.sdk }} +# secrets: inherit + test: +# needs: [setup] runs-on: ubuntu-latest strategy: fail-fast: false @@ -18,72 +23,83 @@ jobs: # Can't run on `dev` (Dart 3) until we're fully null-safe. sdk: [ 2.18.7, 2.19.6 ] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.2 - with: - sdk: ${{ matrix.sdk }} - - - name: Print Dart SDK version - run: dart --version - - - id: install - name: Install dependencies - run: dart pub get - - - name: Validate dependencies - run: dart run dependency_validator - if: always() && steps.install.outcome == 'success' - - - name: Verify formatting - run: dart run dart_dev format --check - # Only run on one sdk version in case there are conflicts - if: always() && matrix.sdk != '2.18.7' && steps.install.outcome == 'success' +# - uses: actions/checkout@v3 +# - uses: dart-lang/setup-dart@v1 +# with: +# sdk: ${{ matrix.sdk }} +# +# - name: Print Dart SDK version +# run: dart --version +# +# - id: install +# name: Install dependencies +# run: dart pub get +# +# - name: Validate dependencies +# run: dart run dependency_validator +# if: always() && steps.install.outcome == 'success' +# +# - name: Verify formatting +# run: dart run dart_dev format --check +# # Only run on one sdk version in case there are conflicts +# if: always() && matrix.sdk != '2.18.7' && steps.install.outcome == 'success' # Analyze before generated files are created to verify that component boilerplate analysis is "clean" without the need for building - - name: Analyze example source (pre-build) - run: | - # Analyze lib to ensure public APIs don't depend on build-to-cache files, - # which could cause analysis issues for consumers who haven't run a build yet. - dart analyze lib - dart analyze example/boilerplate_versions - if: always() && steps.install.outcome == 'success' - - - id: build - timeout-minutes: 6 - name: Build generated files / precompile DDC assets - run: | - dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled - if: always() && steps.install.outcome == 'success' - - - name: Verify that generated files are up-to-date - run: | - if [ ${{ matrix.sdk }} = '2.18.7' ]; then - git diff --exit-code - else - # Don't check these generated files for other SDKs, since they may generate differently - # due to different resolved dependencies. - git diff --exit-code -- ":(exclude)test/mockito.mocks.dart" ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart" - fi - if: always() && steps.install.outcome == 'success' && steps.install.build == 'success' - - # Analyze again after generated files are created to verify that those generated classes don't cause analysis errors - - name: Analyze project source (post-build) - run: dart analyze - if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success' +# - name: Analyze example source (pre-build) +# run: | +# # Analyze lib to ensure public APIs don't depend on build-to-cache files, +# # which could cause analysis issues for consumers who haven't run a build yet. +# dart analyze lib +# dart analyze example/boilerplate_versions +# if: always() && steps.install.outcome == 'success' +# +# - id: build +# timeout-minutes: 6 +# name: Build generated files / precompile DDC assets +# run: | +# dart run build_runner build --delete-conflicting-outputs -o ddc_precompiled +# if: always() && steps.install.outcome == 'success' +# +# - name: Verify that generated files are up-to-date +# run: | +# if [ ${{ matrix.sdk }} = '2.18.7' ]; then +# git diff --exit-code +# else +# # Don't check these generated files for other SDKs, since they may generate differently +# # due to different resolved dependencies. +# git diff --exit-code -- ":(exclude)test/mockito.mocks.dart" ":(exclude)test/over_react/component_declaration/redux_component_test/test_reducer.g.dart" +# fi +# if: always() && steps.install.outcome == 'success' && steps.install.build == 'success' +# +# # Analyze again after generated files are created to verify that those generated classes don't cause analysis errors +# - name: Analyze project source (post-build) +# run: dart analyze +# if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success' + - name: Install + id: setup + uses: ./install.yml + with: + sdk: ${{ matrix.sdk }} - name: Run tests (VM) # Can't use build_runner (which dart_dev uses if you depend on it) to run VM tests, since we get the error: # Unable to spawn isolate: /…/build_runner_testRU6M77/.packages: Error: Problem in packages configuration file: Unexpected character run: dart test -P vm - if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success' - - - name: Run tests (DDC) - run: dart test --precompiled ddc_precompiled -P dartdevc - if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success' + if: steps.setup.outcome == 'success' - name: Run tests (dart2js) run: dart run dart_dev test --build-args="-r" -P dart2js - if: always() && steps.install.outcome == 'success' && steps.build.outcome == 'success' + if: steps.setup.outcome == 'success' + + - name: Build + id: build + uses: ./build.yml + with: + sdk: ${{ matrix.sdk }} + + - name: Run tests (DDC) + run: dart test --precompiled ddc_precompiled -P dartdevc + if: steps.build.outcome == 'success' validate_analyzer: runs-on: ubuntu-latest diff --git a/.github/workflows/dart_tests.yml b/.github/workflows/dart_tests.yml new file mode 100644 index 0000000000..0707160ed2 --- /dev/null +++ b/.github/workflows/dart_tests.yml @@ -0,0 +1,19 @@ +name: test + +on: + workflow_call: + inputs: + sdk: + required: true + +permissions: + contents: read + id-token: write + issues: write + pull-requests: write + +jobs: + ddc: + runs-on: ubuntu-latest + + diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml new file mode 100644 index 0000000000..5b7756f13d --- /dev/null +++ b/.github/workflows/install.yml @@ -0,0 +1,52 @@ +name: install + +on: + workflow_call: + inputs: + sdk: + required: true + +permissions: + contents: read + id-token: write + issues: write + pull-requests: write + +jobs: + install: + runs-on: ubuntu-latest + outputs: + hash: ${{ steps.hash.outputs.result }} + steps: + - uses: actions/checkout@v3 + - uses: dart-lang/setup-dart@v1 + with: + sdk: ${{ inputs.sdk }} + - name: Print Dart SDK version + run: dart --version + - name: Produce hash + id: hash + shell: bash + run: echo "result=${{ runner.os }};${{ hashFiles('**/pubspec.yaml','**/pubspec.lock') || 'none' }}@${{ inputs.sdk }}" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + name: Pub Cache + id: cache + with: + path: .dart_tool + key: ${{ steps.hash.outputs.result }} + + - name: Install Dependencies + id: install + if: steps.cache.outputs.cache-hit != 'true' + run: dart pub get + + check: + needs: [install] + steps: + - name: Validate Dependencies + run: dart run dependency_validator + - name: Verify formatting + # Only run on one sdk version in case there are conflicts + if: inputs.sdk != '2.18.7' + run: dart run dart_dev format --check