Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example on how to use matrix with env vars #1288

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bartekpacia
Copy link
Contributor

@bartekpacia bartekpacia commented Aug 20, 2024

took me too long to figure this out

@bartekpacia
Copy link
Contributor Author

bartekpacia commented Aug 20, 2024

Hmm, I also expected this to generate 4 tasks, but it generates 16:

blah_task:
  name: Build
  container:
    image: alpine:3.20
  env:
    # Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800
    matrix:
      ANDROID_CLT_VERSION: 9123335 # v8, latest compatible with JDK 8+
      JDK_PACKAGE: openjdk-8-jdk
    matrix:
      ANDROID_CLT_VERSION: 9862592 # v10, latest compatible with JDK 11+
      JDK_PACKAGE: openjdk-11-jdk
    matrix:
      ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
      JDK_PACKAGE: openjdk-17-jdk
    matrix:
      ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
      JDK_PACKAGE: openjdk-21-jdk
  info_script:
    - echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_PACKAGE"

There's an easy workaround in this case though

workaround
blah_task:
  name: Build
  container:
    image: alpine:3.20
  env:
    # Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800
    matrix:
      # v8, latest compatible with JDK 8+
      ANDROID_AND_JDK: 9123335:openjdk-8-jdk

      # v10, latest compatible with JDK 11+
      ANDROID_AND_JDK: 9862592:openjdk-11-jdk

      # v13, latest compatible with JDK 17+
      ANDROID_AND_JDK: 11479570:openjdk-17-jdk

      # v13, latest compatible with JDK 17+
      ANDROID_AND_JDK: 11479570:openjdk-21-jdk
  export_env_vars_script:
    - export ANDROID_CLT_VERSION="$(echo $ANDROID_AND_JDK | cut -d ':' -f1)"
    - export JDK_PACKAGE="$(echo $ANDROID_AND_JDK | cut -d ':' -f2)"
    - echo "ANDROID_CLT_VERSION=$ANDROID_CLT_VERSION" >> $CIRRUS_ENV
    - echo "JDK_PACKAGE=$JDK_PACKAGE" >> $CIRRUS_ENV
  info_script:
    - echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_PACKAGE"

@edigaryev
Copy link
Contributor

Hmm, I also expected this to generate 4 tasks, but it generates 16

This should work:

blah_task:
  name: Build
  container:
    image: alpine:3.20
  env:
    # Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800
    matrix:
      - ANDROID_CLT_VERSION: 9123335 # v8, latest compatible with JDK 8+
        JDK_PACKAGE: openjdk-8-jdk
      - ANDROID_CLT_VERSION: 9862592 # v10, latest compatible with JDK 11+
        JDK_PACKAGE: openjdk-11-jdk
      - ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
        JDK_PACKAGE: openjdk-17-jdk
      - ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
        JDK_PACKAGE: openjdk-21-jdk
  info_script:
    - echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_PACKAGE"

Regarding the PR itself, perhaps it should use this syntax too.

fkorotkov
fkorotkov previously approved these changes Aug 26, 2024
Copy link
Contributor

@edigaryev edigaryev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartekpacia
Copy link
Contributor Author

bartekpacia commented Aug 26, 2024

I think the current way is better to generate 6 tasks - less duplication is involved.

I added another example to make it clear that matrix env vars can be also configured on a fine-grained level, just like you showed in #1288 (comment)

edigaryev
edigaryev previously approved these changes Aug 26, 2024
@edigaryev
Copy link
Contributor

It seems that the "Spell Check" is failing because granularly is not present in .spelling.

@bartekpacia
Copy link
Contributor Author

Thanks, fixed.

btw, it seems that the tool used for spellchecking hasn't seen a commit to master in ~4 years, and the latest version is ~7 years old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants