diff --git a/.eslintrc b/.eslintrc index 101ea29..3b7d8a1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,4 +4,3 @@ }, "extends": "eslint-config-discourse" } - diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index 53b1db6..0000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Linting - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v1 - with: - node-version: 12 - - - name: Set up ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: 2.7 - architecture: 'x64' - - - name: Setup bundler - run: gem install bundler -v 2.1.4 --no-doc - - - name: Setup gems - run: bundle install --jobs 4 - - - name: Yarn install - run: yarn install --dev - - - name: ESLint - run: yarn eslint --ext .js --ext .es6 assets/javascripts - - - name: Prettier - run: | - yarn prettier -v - yarn prettier --list-different \ - "assets/stylesheets/**/*.scss" \ - "assets/javascripts/**/*.{js,es6}" - - - name: Rubocop - run: bundle exec rubocop . diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml new file mode 100644 index 0000000..7534015 --- /dev/null +++ b/.github/workflows/plugin-linting.yml @@ -0,0 +1,47 @@ +name: Linting + +on: + push: + branches: + - master + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Set up ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.7 + + - name: Setup bundler + run: gem install bundler -v 2.1.4 --no-doc + + - name: Setup gems + run: bundle install --jobs 4 + + - name: Yarn install + run: yarn install --dev + + - name: ESLint + run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern assets/javascripts + + - name: Prettier + run: | + yarn prettier -v + if [ -d "assets" ]; then \ + yarn prettier --list-different "assets/**/*.{scss,js,es6}" ; \ + fi + + - name: Rubocop + run: bundle exec rubocop . diff --git a/.github/workflows/run_tests.yml b/.github/workflows/plugin-tests.yml similarity index 84% rename from .github/workflows/run_tests.yml rename to .github/workflows/plugin-tests.yml index 2cdfc88..80a05e9 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -1,6 +1,11 @@ name: Plugin Tests -on: [push, pull_request] +on: + push: + branches: + - master + - main + pull_request: jobs: build: @@ -23,7 +28,7 @@ jobs: matrix: build_types: ["BACKEND", "FRONTEND"] - target: ["PLUGINS", "CORE"] + target: ["PLUGINS"] os: [ubuntu-latest] ruby: ["2.6"] postgres: ["12"] @@ -49,18 +54,30 @@ jobs: with: repository: discourse/discourse fetch-depth: 1 - + - name: Install plugin uses: actions/checkout@master with: path: plugins/${{ github.event.repository.name }} - fetch-depth: 1 + fetch-depth: 1 + + - name: Check spec existence + id: check_spec + uses: andstor/file-existence-action@v1 + with: + files: "plugins/${{ github.event.repository.name }}/spec" + + - name: Check qunit existence + id: check_qunit + uses: andstor/file-existence-action@v1 + with: + files: "plugins/${{ github.event.repository.name }}/test/javascripts" - name: Setup Git run: | git config --global user.email "ci@ci.invalid" git config --global user.name "Discourse CI" - + - name: Setup packages run: | sudo apt-get update @@ -91,7 +108,7 @@ jobs: bundle config without 'development' - name: Bundler cache - uses: actions/cache@v1 + uses: actions/cache@v2 id: bundler-cache with: path: vendor/bundle @@ -107,7 +124,7 @@ jobs: run: echo "::set-output name=dir::$(yarn cache dir)" - name: Yarn cache - uses: actions/cache@v1 + uses: actions/cache@v2 id: yarn-cache with: path: ${{ steps.yarn-cache-dir.outputs.dir }} @@ -122,7 +139,7 @@ jobs: run: | bin/rake db:create bin/rake db:migrate - + - name: Create parallel databases if: env.BUILD_TYPE == 'BACKEND' && env.TARGET == 'CORE' run: | @@ -134,17 +151,17 @@ jobs: run: | bin/turbo_rspec bin/rake plugin:spec - + - name: Plugin RSpec - if: env.BUILD_TYPE == 'BACKEND' && env.TARGET == 'PLUGINS' + if: env.BUILD_TYPE == 'BACKEND' && env.TARGET == 'PLUGINS' && steps.check_spec.outputs.files_exists == 'true' run: bin/rake plugin:spec[${{ github.event.repository.name }}] - + - name: Core QUnit if: env.BUILD_TYPE == 'FRONTEND' && env.TARGET == 'CORE' run: bundle exec rake qunit:test['1200000'] timeout-minutes: 30 - - - name: Plugin QUnit # Tests core plugins in TARGET=CORE, and all plugins in TARGET=PLUGINS - if: env.BUILD_TYPE == 'FRONTEND' + + - name: Plugin QUnit + if: env.BUILD_TYPE == 'FRONTEND' && env.TARGET == 'PLUGINS' && steps.check_qunit.outputs.files_exists == 'true' run: bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000'] timeout-minutes: 30 diff --git a/.gitignore b/.gitignore index 35d7586..2c758d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,2 @@ -.DS_Store +node_modules gems -log -.byebug_history -/.idea -node_modules/ -.bundle/ -auto_generated diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.prettierrc @@ -0,0 +1 @@ +{} diff --git a/.template-lintrc.js b/.template-lintrc.js new file mode 100644 index 0000000..a558b8e --- /dev/null +++ b/.template-lintrc.js @@ -0,0 +1,4 @@ +module.exports = { + plugins: ["ember-template-lint-plugin-discourse"], + extends: "discourse:recommended", +}; diff --git a/package.json b/package.json index 05332ef..f57f5b4 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,6 @@ "author": "Discourse", "license": "MIT", "devDependencies": { - "eslint-config-discourse": "latest" + "eslint-config-discourse": "^1.1.3" } } diff --git a/yarn.lock b/yarn.lock index 1b5ddb0..f2559ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -498,10 +498,10 @@ escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= -eslint-config-discourse@latest: - version "1.1.3" - resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.3.tgz#38b85e810cad72280073d659565bf25611331ac3" - integrity sha512-n6ZRuFPMVn+jHpszZhNQwFRsIG1mRq5LrFdbN/WNDW7ohk+iyYyLkwB8btJFms5CcfHLsiiey92EAh3oNavrpw== +eslint-config-discourse@^1.1.3: + version "1.1.6" + resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.6.tgz#3080da848de09a0e533076b817d9cf865df7d571" + integrity sha512-K14qBtyJJeL/5njtksnSgViuTZWk3hjO1kOTqV2iTpukeRlItfJpeOpUhkwm08SBDYEKCH2Ahn/XYWR0RZ75zA== dependencies: babel-eslint "^10.1.0" ember-template-lint "^2.11.0" @@ -511,7 +511,7 @@ eslint-config-discourse@latest: eslint-plugin-ember "^6.10.0" eslint-plugin-lodash "^7.1.0" eslint-plugin-node "^8.0.0" - prettier "^2.1.1" + prettier "2.1.2" eslint-plugin-discourse-ember@latest: version "0.0.3" @@ -1204,7 +1204,7 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@^2.1.1: +prettier@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==