DEV: Update CI workflows (#210)

* DEV: Update CI workflows
* DEV: Fix prettier errors in tests

Co-authored-by: CvX <CvX@users.noreply.github.com>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
discoursebot 2021-09-20 09:52:26 -04:00 committed by GitHub
parent 85fa1f90aa
commit ac0f8a6ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 82 deletions

View File

@ -37,11 +37,10 @@ jobs:
shell: bash shell: bash
run: | run: |
yarn prettier -v yarn prettier -v
shopt -s extglob if [ 0 -lt $(find assets -type f \( -name "*.scss" -or -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
if ls assets/**/*.@(scss|js|es6) &> /dev/null; then
yarn prettier --list-different "assets/**/*.{scss,js,es6}" yarn prettier --list-different "assets/**/*.{scss,js,es6}"
fi fi
if ls test/**/*.@(js|es6) &> /dev/null; then if [ 0 -lt $(find test -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
yarn prettier --list-different "test/**/*.{js,es6}" yarn prettier --list-different "test/**/*.{js,es6}"
fi fi

View File

@ -29,7 +29,6 @@ jobs:
build_type: ["backend", "frontend"] build_type: ["backend", "frontend"]
ruby: ["2.7"] ruby: ["2.7"]
postgres: ["13"] postgres: ["13"]
redis: ["4.x"]
services: services:
postgres: postgres:
@ -63,10 +62,9 @@ jobs:
git config --global user.email "ci@ci.invalid" git config --global user.email "ci@ci.invalid"
git config --global user.name "Discourse CI" git config --global user.name "Discourse CI"
- name: Setup redis - name: Start redis
uses: shogo82148/actions-setup-redis@v1 run: |
with: redis-server /etc/redis/redis.conf &
redis-version: ${{ matrix.redis }}
- name: Bundler cache - name: Bundler cache
uses: actions/cache@v2 uses: actions/cache@v2
@ -113,8 +111,7 @@ jobs:
id: check_spec id: check_spec
shell: bash shell: bash
run: | run: |
shopt -s extglob if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then
if ls plugins/${{ github.event.repository.name }}/spec/**/*.@(rb) &> /dev/null; then
echo "::set-output name=files_exist::true" echo "::set-output name=files_exist::true"
fi fi
@ -126,8 +123,7 @@ jobs:
id: check_qunit id: check_qunit
shell: bash shell: bash
run: | run: |
shopt -s extglob if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
if ls plugins/${{ github.event.repository.name }}/test/javascripts/**/*.@(js|es6) &> /dev/null; then
echo "::set-output name=files_exist::true" echo "::set-output name=files_exist::true"
fi fi

View File

@ -1,7 +1,4 @@
import { import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
acceptance,
exists
} from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import I18n from "I18n"; import I18n from "I18n";

View File

@ -7,33 +7,36 @@ import { click, currentURL, visit } from "@ember/test-helpers";
import AssignedTopics from "../fixtures/assigned-topics-fixtures"; import AssignedTopics from "../fixtures/assigned-topics-fixtures";
import { test } from "qunit"; import { test } from "qunit";
acceptance("Discourse Assign | Quick access assignments panel", function (needs) { acceptance(
needs.user(); "Discourse Assign | Quick access assignments panel",
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" }); function (needs) {
needs.user();
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
needs.pretender((server, helper) => { needs.pretender((server, helper) => {
const messagesPath = "/topics/messages-assigned/eviltrout.json"; const messagesPath = "/topics/messages-assigned/eviltrout.json";
const assigns = AssignedTopics[messagesPath]; const assigns = AssignedTopics[messagesPath];
server.get(messagesPath, () => helper.response(assigns)); server.get(messagesPath, () => helper.response(assigns));
}); });
test("Quick access assignments panel", async (assert) => { test("Quick access assignments panel", async (assert) => {
updateCurrentUser({ can_assign: true }); updateCurrentUser({ can_assign: true });
await visit("/"); await visit("/");
await click("#current-user.header-dropdown-toggle"); await click("#current-user.header-dropdown-toggle");
await click(".widget-button.assigned"); await click(".widget-button.assigned");
const assignment = query(".quick-access-panel li a"); const assignment = query(".quick-access-panel li a");
assert.ok(assignment.innerText.includes("Greetings!")); assert.ok(assignment.innerText.includes("Greetings!"));
assert.ok(assignment.href.includes("/t/greetings/10/5")); assert.ok(assignment.href.includes("/t/greetings/10/5"));
await click(".widget-button.assigned"); await click(".widget-button.assigned");
assert.equal( assert.equal(
currentURL(), currentURL(),
"/u/eviltrout/activity/assigned", "/u/eviltrout/activity/assigned",
"a second click should redirect to the full assignments page" "a second click should redirect to the full assignments page"
); );
}); });
}); }
);

View File

@ -1,8 +1,5 @@
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { fillIn, visit } from "@ember/test-helpers"; import { fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";

View File

@ -1,47 +1,58 @@
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
import {acceptance, count, exists} from "discourse/tests/helpers/qunit-helpers"; import {
import {visit} from "@ember/test-helpers"; acceptance,
count,
exists,
} from "discourse/tests/helpers/qunit-helpers";
import { visit } from "@ember/test-helpers";
import AssignedTopics from "../fixtures/assigned-topics-fixtures"; import AssignedTopics from "../fixtures/assigned-topics-fixtures";
import {test} from "qunit"; import { test } from "qunit";
acceptance("Discourse Assign | UnAssign/Re-assign from the topics list", function (needs) { acceptance(
needs.user(); "Discourse Assign | UnAssign/Re-assign from the topics list",
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" }); function (needs) {
needs.pretender((server, helper) => { needs.user();
const messagesPath = "/topics/messages-assigned/eviltrout.json"; needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
const assigns = AssignedTopics[messagesPath]; needs.pretender((server, helper) => {
server.get(messagesPath, () => helper.response(assigns)); const messagesPath = "/topics/messages-assigned/eviltrout.json";
}); const assigns = AssignedTopics[messagesPath];
server.get(messagesPath, () => helper.response(assigns));
});
test("Unassign/Re-assign options are visible", async (assert) => { test("Unassign/Re-assign options are visible", async (assert) => {
const options = selectKit(".assign-actions-dropdown"); const options = selectKit(".assign-actions-dropdown");
await visit("/u/eviltrout/activity/assigned"); await visit("/u/eviltrout/activity/assigned");
await options.expand(); await options.expand();
assert.equal(count("li[data-value='unassign']"), 1); assert.equal(count("li[data-value='unassign']"), 1);
assert.equal(count("li[data-value='reassign']"), 1); assert.equal(count("li[data-value='reassign']"), 1);
}); });
}); }
);
acceptance("Discourse Assign | A user doesn't have assignments", function (needs) { acceptance(
needs.user(); "Discourse Assign | A user doesn't have assignments",
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" }); function (needs) {
needs.pretender((server, helper) => { needs.user();
const assignments = AssignedTopics["/topics/messages-assigned/eviltrout.json"]; needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
assignments.topic_list.topics = []; needs.pretender((server, helper) => {
server.get( const assignments =
"/topics/messages-assigned/eviltrout.json", AssignedTopics["/topics/messages-assigned/eviltrout.json"];
() => helper.response(assignments)); assignments.topic_list.topics = [];
}); server.get("/topics/messages-assigned/eviltrout.json", () =>
helper.response(assignments)
);
});
test("It renders the empty state panel", async function (assert) { test("It renders the empty state panel", async function (assert) {
await visit("/u/eviltrout/activity/assigned"); await visit("/u/eviltrout/activity/assigned");
assert.ok(exists("div.empty-state")); assert.ok(exists("div.empty-state"));
}); });
test("It does not render the search form", async function (assert) { test("It does not render the search form", async function (assert) {
await visit("/u/eviltrout/activity/assigned"); await visit("/u/eviltrout/activity/assigned");
assert.notOk(exists("div.topic-search-div")); assert.notOk(exists("div.topic-search-div"));
}); });
}); }
);