calcitem / Sanmill

Sanmill is an open-source, UCI-like Mill/Morris/Merrills/Mühle/Malom (and its variants) program with CUI, Flutter GUI and Qt GUI, sharing and freely distributing the code, tools and data needed to deliver this mill game. We do this because we are convinced that open software and open data are key ingredients to make rapid progress.
https://play.google.com/store/apps/details?id=com.calcitem.sanmill
GNU General Public License v3.0
149 stars 21 forks source link

CI optimization #411

Open Leptopoda opened 3 years ago

Leptopoda commented 3 years ago

Describe the bug

calcitem commented 3 years ago

Good idea!

Reference: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions https://github.com/tj-actions/verify-changed-files

calcitem commented 3 years ago

The first problem has been solved. I don’t know how to solve the second problem. I did not find a specific example in the official document. I don’t understand the simple example of need.

Leptopoda commented 3 years ago

to use the needs keyword you need to specify both jobs in the same file. something like:

name: Flutter

on:
  push:
  pull_request:
    branches: [ master ]

jobs:
  linter:
    runs-on: ubuntu-latest
    name: Lint flutter code
    steps:
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Set up Flutter
      uses: subosito/flutter-action@v1
    - run: bash -x ./flutter-init.sh
    - run: cp -f ./src/ui/flutter_app/analysis_options.yaml ./
    - name: Analyze Flutter
      uses: ValentinVignal/action-dart-analyze@v0.11
      with:
        fail-on: 'format'
        working-directory: src/ui/flutter_app

  build:
    runs-on: ubuntu-latest
    needs: linter

    # Note that this workflow uses the latest stable version of the Dart SDK.
    # Docker images for other release channels - like dev and beta - are also
    # available. See https://hub.docker.com/r/google/dart/ for the available
    # images.
    #container:
    #  image:  google/dart:latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: '12.x'
      - run: echo $SIGNING_KEY | base64 -d > src/ui/flutter_app/android/app/key.jks
        env:
          SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
      - uses: subosito/flutter-action@v1
        with:
          flutter-version: '2.5.3'

      - name: Export environment valuables
        run: export

      - name: Create App version
        run: git fetch --tags; git tag; git log -n1; bash -x ./version.sh

      - name: Print Flutter SDK version
        run: flutter --version

      - name: Install dependencies
        run: bash -x ./flutter-init.sh

      # Uncomment this step to verify the use of 'dart format' on each commit.
      # - name: Verify formatting
      #   run: dart format --output=none --set-exit-if-changed .

      # Your project will need to have tests in test/ and a dependency on
      # package:test for this step to succeed. Note that Flutter projects will
      # want to change this to 'flutter test'.
      #- name: Run tests
      #  run: dart test

      # Build
      - name: Build apk
        run: cd src/ui/flutter_app; flutter build apk -v; flutter build appbundle -v
        env:
          KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
          KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
          ALIAS: ${{ secrets.ALIAS }}
          KEY_PATH: key.jks

      # Archive apk
      - name: Archive apk
        uses: actions/upload-artifact@v2
        with:
          name: sanmill-flutter-apk-release
          path: src/ui/flutter_app/build/app/outputs/flutter-apk/app-release.apk

      # Archive aab
      - name: Archive aab
        uses: actions/upload-artifact@v2
        with:
          name: sanmill-flutter-aab-release
          path: src/ui/flutter_app/build/app/outputs/bundle/release/app-release.aab

THIS IS NOT FINAL as it doesn't your recent fix for excluding the Qt dirs ...

You should probably also unify the CUI build into a separate CI (but don't depend on each other) this would unify the excluded dirs...

Leptopoda commented 3 years ago

also the comment # Archive apk in the CUI CI files is a bit off :upside_down_face:

calcitem commented 3 years ago

I’m not sure if jobs on different OS can be merged into a file. Is there an example?

Leptopoda commented 3 years ago

I don't see a reason why it shouldn't.

The platform is defined on a per job basis ...

I'll have a look tomorrow

calcitem commented 3 years ago

Thanks! I will have a try.

calcitem commented 3 years ago

Fixed. https://github.com/calcitem/Sanmill/pull/414

Leptopoda commented 2 years ago

reopening as I have a few new ideas:

This change should allow us to push to draft PRs without building every time. converting the draft to a normal pr would then run the CI. If the proposed changes don't bring the intended results some other fix might need to be found...

calcitem commented 2 years ago

I'm looking for some examples and see if I can find them.

Leptopoda commented 2 years ago

something like:

on:
  push:
    branches: [master, dev]
  pull_request:

This will run on pulls that are made directly onto the master or dev branch but only on PRs for the other branches. I think (but am not shure) that this will prevent it from running on draft PRs