From 9876d9c90f28e3bb5c3f6269c5b3e231c637339f Mon Sep 17 00:00:00 2001 From: Karthikeyan S Date: Fri, 23 Feb 2024 19:02:21 +0530 Subject: [PATCH] ci: add versions.env to unify flutter and dart versions --- .github/workflows/app.yml | 32 +++++++++++++++----------------- .github/workflows/main.yml | 24 +----------------------- .github/workflows/publish.yml | 2 ++ .github/workflows/versions.env | 2 ++ 4 files changed, 20 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/versions.env diff --git a/.github/workflows/app.yml b/.github/workflows/app.yml index a73b9605..74100a3b 100644 --- a/.github/workflows/app.yml +++ b/.github/workflows/app.yml @@ -2,15 +2,6 @@ name: "All the sdk specific jobs" on: workflow_call: - inputs: - flutter_version: - description: "The flutter version used for tests and builds" - type: string - required: true - dart_version: - description: "The dart version used for tests and builds" - type: string - required: true jobs: e2ee_test: @@ -22,13 +13,14 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v3 + - run: cat .github/workflows/versions.env >> $GITHUB_ENV - name: Run tests run: | export NETWORK='--network mynet' docker network create mynet # deploy homeserver instance scripts/integration-server-${{matrix.homeserver}}.sh - docker run $NETWORK --env GITHUB_ACTIONS="${GITHUB_ACTIONS}" --env HOMESERVER_IMPLEMENTATION="${{matrix.homeserver}}" --env HOMESERVER="${{startsWith('dendrite', matrix.homeserver) && format('{0}:8008', matrix.homeserver) || matrix.homeserver }}" --volume="$(pwd):/workdir" --workdir /workdir ghcr.io/famedly/container-image-flutter/flutter:${{inputs.flutter_version}} /bin/bash -c "set -e + docker run $NETWORK --env GITHUB_ACTIONS="${GITHUB_ACTIONS}" --env HOMESERVER_IMPLEMENTATION="${{matrix.homeserver}}" --env HOMESERVER="${{startsWith('dendrite', matrix.homeserver) && format('{0}:8008', matrix.homeserver) || matrix.homeserver }}" --volume="$(pwd):/workdir" --workdir /workdir ghcr.io/famedly/container-image-flutter/flutter:${{env.flutter_version}} /bin/bash -c "set -e scripts/integration-prepare-alpine.sh # create test user environment variables source scripts/integration-create-environment-variables.sh @@ -42,11 +34,13 @@ jobs: # coverage_without_olm is done on dart images because why not :D coverage: runs-on: ubuntu-latest - container: - image: ghcr.io/famedly/container-image-flutter/flutter-linux:${{inputs.flutter_version}} - options: --user root steps: - uses: actions/checkout@v3 + - run: cat .github/workflows/versions.env >> $GITHUB_ENV + - uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa + with: + flutter-version: ${{ env.flutter_version }} + cache: true - name: Run tests run: | sed -i 's/#flutter_test/flutter_test/g' pubspec.yaml @@ -56,12 +50,14 @@ jobs: coverage_without_olm: runs-on: ubuntu-latest - container: - image: dart:${{inputs.dart_version}} env: NO_OLM: 1 steps: - uses: actions/checkout@v3 + - run: cat .github/workflows/versions.env >> $GITHUB_ENV + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + with: + sdk: ${{ env.dart_version }} - name: Run tests run: | apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl lcov python3 python3-distutils libsqlite3-dev @@ -71,10 +67,12 @@ jobs: pub-dev-dry-run: runs-on: ubuntu-latest - container: - image: dart:${{inputs.dart_version}} steps: - uses: actions/checkout@v3 + - run: cat .github/workflows/versions.env >> $GITHUB_ENV + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + with: + sdk: ${{ env.dart_version }} - name: pub.dev publish dry run run: | dart pub get diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f4e5780..9531e678 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,31 +13,13 @@ concurrency: group: ${{ github.ref }} cancel-in-progress: true -env: - FLUTTER_VERSION: 3.10.6 - DART_VERSION: 3.0.6 - jobs: - # because there is no easy way to pass env variables to jobs - versions: - runs-on: ubuntu-latest - outputs: - flutter_version: ${{ steps.flutterver.outputs.FLUTTER_VERSION }} - dart_version: ${{ steps.dartver.outputs.DART_VERSION }} - steps: - - id: flutterver - run: echo "FLUTTER_VERSION=${{ env.FLUTTER_VERSION }}" >> "$GITHUB_OUTPUT" - - id: dartver - run: echo "DART_VERSION=${{ env.DART_VERSION }}" >> "$GITHUB_OUTPUT" - dart: permissions: contents: read uses: famedly/frontend-ci-templates/.github/workflows/dart.yml@main - needs: [versions] with: - flutter_version: ${{ needs.versions.outputs.flutter_version }} - dart_version: ${{ needs.versions.outputs.dart_version }} + env_file: ".github/workflows/versions.env" secrets: ssh_key: "${{ secrets.CI_SSH_PRIVATE_KEY }}" @@ -49,7 +31,3 @@ jobs: app_jobs: secrets: inherit uses: ./.github/workflows/app.yml - needs: [versions] - with: - flutter_version: ${{ needs.versions.outputs.flutter_version }} - dart_version: ${{ needs.versions.outputs.dart_version }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index de10fd3a..b8c82cdb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,3 +12,5 @@ jobs: contents: read id-token: write uses: famedly/frontend-ci-templates/.github/workflows/publish-pub.yml@main + with: + env_file: ".github/workflows/versions.env" diff --git a/.github/workflows/versions.env b/.github/workflows/versions.env new file mode 100644 index 00000000..08f97c5e --- /dev/null +++ b/.github/workflows/versions.env @@ -0,0 +1,2 @@ +flutter_version=3.10.6 +dart_version=3.0.6