Skip to content

Commit

Permalink
Merge pull request #168 from peopledoc/ci-reuse-org-workflows
Browse files Browse the repository at this point in the history
CI - Reuse organisation's workflows to lint, test, tag and publish
  • Loading branch information
MrChocolatine authored Nov 2, 2021
2 parents ecb3fbc + f8740c1 commit f0b7550
Show file tree
Hide file tree
Showing 14 changed files with 371 additions and 492 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# misc
/coverage/
!.*
.*/
.eslintcache

# ember-try
Expand Down
28 changes: 14 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,15 @@ module.exports = {
// node files
{
files: [
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js',
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**',
'./.eslintrc.js',
'./.prettierrc.js',
'./.template-lintrc.js',
'./ember-cli-build.js',
'./index.js',
'./testem.js',
'./blueprints/*/index.js',
'./config/**/*.js',
'./tests/dummy/config/**/*.js',
],
parserOptions: {
sourceType: 'script',
Expand All @@ -80,6 +75,11 @@ module.exports = {
plugins: ['node'],
extends: ['plugin:node/recommended'],
},
{
// Test files:
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},

// TypeScript related

Expand Down
91 changes: 6 additions & 85 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,17 @@
# GitHub Actions documentation:
# https://docs.github.com/en/actions

name: CI

on:
push:
branches:
- master
branches: master
pull_request: {}

env:
NODE_VERSION: 12

concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

# https://github.com/lirantal/lockfile-lint
- name: Lint lockfile
run: >
npm_config_yes=true npx lockfile-lint
--path yarn.lock
--allowed-hosts npm yarn
--validate-https
- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Lint
run: yarn run lint

- name: Run Tests
run: yarn run test:ember

floating:
name: Floating Dependencies
needs: test
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

- name: Install Dependencies
run: yarn install --no-lockfile --non-interactive

- name: Run Tests
run: yarn run test:ember

try-scenarios:
name: ${{ matrix.try-scenario }}
needs: test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
try-scenario:
- ember-lts-3.16
- ember-lts-3.20
- ember-release
- ember-classic
- ember-default-with-jquery
- embroider-safe
- embroider-optimized

steps:
- uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Run Tests
run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }}
org:
uses: peopledoc/.github/.github/workflows/js--emberjs-addons-ci.yml@main
68 changes: 9 additions & 59 deletions .github/workflows/tag-release-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GitHub Actions workflows:
# GitHub Actions documentation:
# https://docs.github.com/en/actions

name: Create new `git tag`, create new GitHub release and publish to NPM
Expand All @@ -9,63 +9,13 @@ on:
branches: master
types: completed

concurrency:
group: tag-release-publish-${{ github.ref }}
cancel-in-progress: true

jobs:
create-git-tag:
org:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Create new `git tag`
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
new-tag: ${{ steps.detect-and-tag-new-version.outputs.tag }}
new-version: ${{ steps.detect-and-tag-new-version.outputs.current-version }}
old-version: ${{ steps.detect-and-tag-new-version.outputs.previous-version }}
steps:
- uses: actions/checkout@v2
with:
# Required to ensure git history is properly checked:
# https://github.com/salsify/action-detect-and-tag-new-version/blob/v2.0.1/README.md?plain=1#L11
fetch-depth: 2

- name: Detect and tag new version
id: detect-and-tag-new-version
uses: salsify/action-detect-and-tag-new-version@v2

create-github-release:
if: ${{ needs.create-git-tag.outputs.new-tag }}
name: Create new GitHub release
needs: create-git-tag
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: ncipollo/release-action@v1
env:
REPO_URL: '${{ github.server_url }}/${{ github.repository }}'
TAGS_DIFF: 'v${{ needs.create-git-tag.outputs.old-version }}...v${{ needs.create-git-tag.outputs.new-version }}'
with:
body: 'Changelog: ${{ env.REPO_URL }}/compare/${{ env.TAGS_DIFF }}'
name: Release ${{ needs.create-git-tag.outputs.new-tag }}
tag: ${{ needs.create-git-tag.outputs.new-tag }}

publish-npm:
if: ${{ needs.create-git-tag.outputs.new-tag }}
name: Publish to NPM
needs: create-git-tag
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 12
# Required if we want to authenticate during the `npm publish`:
# https://github.com/actions/setup-node/blob/v2.4.1/action.yml#L15-L16
registry-url: https://registry.npmjs.org

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
uses: peopledoc/.github/.github/workflows/js--tag-release-publish.yml@main
secrets:
npm_automation_token: ${{ secrets.NPM_AUTOMATION_TOKEN }}
2 changes: 1 addition & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'

module.exports = {
extends: 'octane',
extends: 'recommended',
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

## Linting

* `yarn run lint`
* `yarn run lint:fix`
* `yarn lint`
* `yarn lint:fix`

## Running tests

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ We found it especially useful, for example, when migrating an existing app to Em

## Compatibility

- Ember.js v3.16 or above
- Ember CLI v3.16 or above
- Ember.js v3.20 or above
- Ember CLI v3.20 or above
- Node.js v12 or above


Expand Down
11 changes: 7 additions & 4 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ module.exports = async function () {
useYarn: true,
scenarios: [
{
name: 'ember-lts-3.16',
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.16.0',
'ember-source': '~3.20.5',
},
},
},
{
name: 'ember-lts-3.20',
name: 'ember-lts-3.24',
npm: {
devDependencies: {
'ember-source': '~3.20.5',
'ember-source': '~3.24.3',
},
},
},
Expand Down Expand Up @@ -55,6 +55,9 @@ module.exports = async function () {
}),
},
npm: {
devDependencies: {
'ember-source': '~3.28.0',
},
ember: {
edition: 'classic',
},
Expand Down
8 changes: 7 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ module.exports = function (defaults) {
behave. You most likely want to be modifying `./index.js` or app's build file
*/

return maybeEmbroider(app)
return maybeEmbroider(app, {
skipBabel: [
{
package: 'qunit',
},
],
})
}
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
"postpack": "ember ts:clean"
},
"dependencies": {
"ember-cli-babel": "^7.26.5",
"ember-cli-babel": "^7.26.6",
"ember-cli-htmlbars": "^6.0.0",
"ember-cli-typescript": "^4.2.1"
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.4.0",
"@ember/test-helpers": "^2.4.2",
"@embroider/test-setup": "^0.47.0",
"@types/ember-qunit": "^3.4.14",
"@types/ember-resolver": "^5.0.10",
Expand All @@ -71,31 +71,32 @@
"@typescript-eslint/parser": "^4.30.0",
"babel-eslint": "^10.1.0",
"ember-auto-import": "^1.11.3",
"ember-cli": "~3.24.0",
"ember-cli": "~3.28.3",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-terser": "^4.0.2",
"ember-cli-typescript-blueprints": "^3.0.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^1.0.0",
"ember-qunit": "^5.1.1",
"ember-qunit": "^5.1.4",
"ember-resolver": "^8.0.2",
"ember-source": "~3.26.1",
"ember-source": "~3.28.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^3.5.1",
"ember-template-lint": "^3.6.0",
"ember-try": "^1.4.0",
"eslint": "^7.32.0",
"eslint-plugin-ember": "^10.5.1",
"eslint-plugin-ember": "^10.5.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-qunit": "^6.2.0",
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"qunit": "^2.17.0",
"qunit-dom": "^2.0.0",
"typescript": "^4.3.5"
},
"engines": {
"node": "12.* || 14.*"
"node": "12.* || 14.* || >= 16"
},
"ember": {
"edition": "octane"
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/config/ember-cli-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": [
{
"name": "ember-cli",
"version": "3.24.0",
"version": "3.28.3",
"blueprints": [
{
"name": "addon",
Expand Down
7 changes: 0 additions & 7 deletions tests/dummy/config/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ const browsers = [
'last 1 Safari versions',
]

const isCI = Boolean(process.env.CI)
const isProduction = process.env.EMBER_ENV === 'production'

if (isCI || isProduction) {
browsers.push('ie 11')
}

module.exports = {
browsers,
}
2 changes: 1 addition & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
</div>

<script src="/testem.js" integrity=""></script>
<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/test-support.js"></script>
<script src="{{rootURL}}assets/dummy.js"></script>
Expand Down
Loading

0 comments on commit f0b7550

Please sign in to comment.