jelhan / create-github-actions-setup-for-ember-addon

Setup GitHub Actions for an Ember Addon
MIT License
19 stars 2 forks source link

Support arbitary environment variables in job configuration #12

Open jelhan opened 3 years ago

jelhan commented 3 years ago

So far only EMBER_CLI_SCENARIO environment variable is extracted from .travis.yml configuration and used to generate the GitHub Action CI: https://github.com/jelhan/create-github-actions-setup-for-ember-addon/blob/e518896b9bed309ae419736f4e8f57d76cfa0c69/src/utils/parse-travis-ci-config.ts#L65-L74 https://github.com/jelhan/create-github-actions-setup-for-ember-addon/blob/e518896b9bed309ae419736f4e8f57d76cfa0c69/templates/.github/workflows/ci.yml#L204-L207

It should be possible to migrate every environment variable defined in TravisCI in that way to GitHub Actions. Instead of ignoring all environment variables, which aren't EMBER_CLI_SCENARIO, we could use a key value map to store them and loop over it in the GitHub Actions creation.

We would need to change the configuration used to generate GitHub Actions. https://github.com/jelhan/create-github-actions-setup-for-ember-addon/blob/e518896b9bed309ae419736f4e8f57d76cfa0c69/src/index.ts#L33-L48

Maybe something like this:

 const data: ConfigurationInterface = parseTravisCiConfig() ?? {
   browsers: ['chrome', 'firefox'],
-  emberTryScenarios: {
-    required: [
-      'ember-lts-3.16',
-      'ember-lts-3.20',
-      'ember-release',
-      'ember-beta',
-      'ember-default-with-jquery',
-      'ember-classic',
-    ],
-    allowedToFail: ['ember-canary', 'embroider-tests'],
-  },
+ jobs: [
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'ember-lts-3.16',
+     },
+     allowedToFail: false,
+   },
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'ember-lts-3.20',
+     },
+     allowedToFail: false,
+   },
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'ember-release',
+     },
+     allowedToFail: false,
+   },
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'ember-beta',
+     },
+     allowedToFail: false,
+   },
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'default-with-jquery',
+     },
+     allowedToFail: false,
+   },
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'ember-canary',
+     },
+     allowedToFail: true,
+   },
+   {
+     environmentVariables: {
+       EMBER_CLI_SCENARIO: 'embroider-tests',
+     },
+     allowedToFail: true,
+   },
+ ]
   nodeVersion: '10.x',
   packageManager: 'yarn',
 };
jelhan commented 3 years ago

I was going through all Adopted Ember Addons. None of them uses environment variables in a way which would be supported by this feature. Maybe the need for it isn't that high?