From 3b18a1f35d8737da902dd0b44d04bcfd1c74b308 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 29 Oct 2023 07:58:05 +0100 Subject: [PATCH] feat(ci): Validate code generation Signed-off-by: jld3103 --- .github/workflows/generate.yaml | 87 +++++++++++++++++++ .../dynamite_end_to_end_test/generate.sh | 8 -- .../dynamite_end_to_end_test/pubspec.yaml | 1 - .../test/ensure_validity_test.dart | 13 --- tool/generate-dynamite-e2e-test.sh | 4 +- 5 files changed, 90 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/generate.yaml delete mode 100644 packages/dynamite/dynamite_end_to_end_test/generate.sh delete mode 100644 packages/dynamite/dynamite_end_to_end_test/test/ensure_validity_test.dart diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml new file mode 100644 index 00000000..25e6dcc8 --- /dev/null +++ b/.github/workflows/generate.yaml @@ -0,0 +1,87 @@ +name: Generate +on: + push: + branches: + - main + pull_request: + +concurrency: + group: generate-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + changes: + name: Check changes + runs-on: ubuntu-22.04 + outputs: + src: ${{ steps.changes.outputs.src}} + steps: + - uses: dorny/paths-filter@v2 + id: changes + continue-on-error: true + with: + filters: | + src: + - external/** + - tool/** + - packages/dynamite/** + - packages/nextcloud/** + + dart: + name: Dart + runs-on: ubuntu-22.04 + needs: changes + if: needs.changes.outputs.src != 'false' + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + fetch-depth: 0 + + - name: Install dart + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1 + - name: Setup + run: ./tool/setup.sh + + - name: Generate dynamite end to end test + run: | + ./tool/generate-dynamite-e2e-test.sh + if [ -n "$(git status --porcelain)" ]; then + git --no-pager diff + exit 1 + fi + + - name: Generate nextcloud + run: | + ./tool/generate-nextcloud.sh + if [ -n "$(git status --porcelain)" ]; then + git --no-pager diff + exit 1 + fi + + openapi: + name: OpenAPI + runs-on: ubuntu-22.04 + needs: changes + if: needs.changes.outputs.src != 'false' + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + fetch-depth: 0 + - name: Submodules + run: git submodule update --init --depth 0 + + - name: Install php + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + tools: composer + + - name: Generate specs + run: | + ./tool/generate-specs.sh + if [ -n "$(git status --porcelain)" ]; then + git --no-pager diff + exit 1 + fi diff --git a/packages/dynamite/dynamite_end_to_end_test/generate.sh b/packages/dynamite/dynamite_end_to_end_test/generate.sh deleted file mode 100644 index e0cfb2f0..00000000 --- a/packages/dynamite/dynamite_end_to_end_test/generate.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -euxo pipefail - -( - fvm dart pub run build_runner build --delete-conflicting-outputs - fvm dart fix --apply lib/ - melos run format -) diff --git a/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml b/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml index b48de226..33dd3021 100644 --- a/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml +++ b/packages/dynamite/dynamite_end_to_end_test/pubspec.yaml @@ -18,7 +18,6 @@ dependencies: dev_dependencies: build_runner: ^2.4.6 - build_verify: ^3.1.0 built_value_generator: ^8.6.3 dynamite: git: diff --git a/packages/dynamite/dynamite_end_to_end_test/test/ensure_validity_test.dart b/packages/dynamite/dynamite_end_to_end_test/test/ensure_validity_test.dart deleted file mode 100644 index b951ffa0..00000000 --- a/packages/dynamite/dynamite_end_to_end_test/test/ensure_validity_test.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:build_verify/build_verify.dart'; -import 'package:test/test.dart'; - -void main() { - test( - 'ensure_build', - () async => expectBuildClean( - packageRelativeDirectory: 'packages/dynamite/dynamite_end_to_end_test', - customCommand: ['bash', 'generate.sh'], - ), - timeout: const Timeout.factor(20), - ); -} diff --git a/tool/generate-dynamite-e2e-test.sh b/tool/generate-dynamite-e2e-test.sh index 7e8b77f7..8b052c17 100755 --- a/tool/generate-dynamite-e2e-test.sh +++ b/tool/generate-dynamite-e2e-test.sh @@ -5,5 +5,7 @@ cd "$(dirname "$0")/.." ( cd packages/dynamite/dynamite_end_to_end_test rm -rf .dart_tool/build/generated/dynamite - bash generate.sh + fvm dart pub run build_runner build --delete-conflicting-outputs + fvm dart fix --apply lib/ + melos run format )