Skip to content

Commit

Permalink
BREAKING Migrate to V2 Addon (#258)
Browse files Browse the repository at this point in the history
* BREAKING split addon and test-app folders into a monorepo

* tests(CI): copy the complete CI config and adapt it to new working directories

* build: convert the addon to V2

* build: change import/export as rollup cannot import namespaces

* build: use relative import so rollup does not treat ember-slugify as internal dependency

* build: fix import in test-app, update ember-try to v3 to fix a fs-extra bug

* rename addon folder, refactor scripts, build the addon on CI

* build: apply greatwizard's suggestions (see PR comment)

* ci: update the release config, no lint on all scenarios for Lint and Test
  • Loading branch information
BlueCutOfficial authored Apr 27, 2023
1 parent 2aac496 commit 0ebf0b8
Show file tree
Hide file tree
Showing 56 changed files with 2,471 additions and 1,589 deletions.
144 changes: 127 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,133 @@ on:
- master
pull_request: {}

jobs:
lint-tests:
name: Lint and tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16

# https://github.com/lirantal/lockfile-lint
- name: Lint lockfile
run: npx lockfile-lint --path yarn.lock --allowed-hosts npm yarn --validate-https

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

- name: Lint Addon
run: yarn lint
working-directory: ember-slugify

- name: Lint Test App
run: yarn lint
working-directory: test-app

- name: Build Addon
run: yarn build

- name: Run Tests
run: yarn test:ember

floating:
name: Floating Dependencies
needs: lint-tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16

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

- name: Build Addon
run: yarn build

- name: Run Tests
run: yarn test:ember
working-directory: test-app

try-scenarios:
name: ${{ matrix.try-scenario }}
needs: lint-tests
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
try-scenario:
- ember-lts-3.28
- ember-lts-4.4
- ember-release
# - ember-beta
# - ember-canary
- ember-classic
- embroider-safe
- embroider-optimized
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version: 16

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

- name: Build Addon
run: yarn build

- name: Run Tests
run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }}
working-directory: test-app

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

jobs:
org:
uses: DazzlingFugu/.github/.github/workflows/js--emberjs-addons.yml@master
with:
node-version: 16
package-manager: yarn
ember-try-scenarios: "[
'ember-lts-3.28',
'ember-lts-4.4',
'ember-release',
'ember-beta',
'ember-canary',
'ember-classic',
'embroider-safe',
'embroider-optimized',
]"
# To reuse when the shared workflow will be migrated to V2 Addons structure
# name: CI
#
# on:
# push:
# branches:
# - master
# pull_request: {}
#
# concurrency:
# group: ci-${{ github.head_ref || github.ref }}
# cancel-in-progress: true
#
# jobs:
# org:
# uses: DazzlingFugu/.github/.github/workflows/js--emberjs-addons.yml@master
# with:
# node-version: 16
# package-manager: yarn
# ember-try-scenarios: "[
# 'ember-lts-3.28',
# 'ember-lts-4.4',
# 'ember-release',
# 'ember-beta',
# 'ember-canary',
# 'ember-classic',
# 'embroider-safe',
# 'embroider-optimized',
# ]"
70 changes: 62 additions & 8 deletions .github/workflows/tag-release-publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GitHub Actions documentation:
# https://docs.github.com/en/actions

name: Create new `git tag`, create new GitHub release and publish to NPM
name: Create new tag, create new GitHub release and publish to NPM

on:
workflow_run:
Expand All @@ -17,11 +17,65 @@ concurrency:
cancel-in-progress: true

jobs:
org:
create_git_tag:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: DazzlingFugu/.github/.github/workflows/js--tag-release-publish.yml@master
with:
node-version: 16
package-manager: yarn
secrets:
npm-automation-token: ${{ secrets.NPM_AUTOMATION_TOKEN }}
name: Create new tag
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
new_tag: ${{ steps.detect_then_tag.outputs.tag }}
new_version: ${{ steps.detect_then_tag.outputs.current-version }}
old_version: ${{ steps.detect_then_tag.outputs.previous-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Detect and tag new version
id: detect_then_tag
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
with:
body: "\
Changelog: \
${{ github.server_url }}/${{ github.repository }}\
/compare/\
v${{ needs.create_git_tag.outputs.old_version }}...v${{ needs.create_git_tag.outputs.new_version }}\
"
name: Release ${{ needs.create_git_tag.outputs.new_tag }}
tag: ${{ needs.create_git_tag.outputs.new_tag }}

publish_npm:
name: Publish to NPM
needs: create_github_release
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
registry-url: https://registry.npmjs.org

- name: Install Dependencies
run: yarn install --frozen-lockfile
working-directory: ember-slugify

- name: Publish to NPM
run: npm publish
working-directory: ember-slugify
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}
35 changes: 3 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try

# broccoli-debug
/DEBUG/
node_modules
yarn-error.log
.DS_Store
22 changes: 11 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

## Installation

* `git clone <repository-url>`
* `cd ember-slugify`
* `yarn install`
- `git clone <repository-url>`
- `cd ember-slugify`
- `yarn install`

## Linting

* `yarn lint`
* `yarn lint:fix`
- `yarn lint`
- `yarn lint:fix`

## Running tests

* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions
- `ember test` – Runs the test suite on the current Ember version
- `ember test --server` – Runs the test suite in "watch mode"
- `ember try:each` – Runs the test suite against multiple Ember versions

## Running the dummy application
## Running the test application

* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
- `ember serve`
- Visit the test application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/).
1 change: 0 additions & 1 deletion app/helpers/remove-diacritics.js

This file was deleted.

1 change: 0 additions & 1 deletion app/helpers/slugify.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions config/environment.js

This file was deleted.

15 changes: 15 additions & 0 deletions ember-slugify/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
dist/

# dependencies
node_modules/

# misc
/coverage/
!.*
.*/
.eslintcache
47 changes: 47 additions & 0 deletions ember-slugify/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict'

module.exports = {
root: true,
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true,
},
requireConfigFile: false,
},
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true,
},
rules: {
semi: ['error', 'never'],
},
overrides: [
// node files
{
files: [
'./.eslintrc.js',
'./.prettierrc.js',
'./.template-lintrc.js',
'./addon-main.js',
'./config/**/*.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended'],
},
],
}
Loading

0 comments on commit 0ebf0b8

Please sign in to comment.