Skip to content

Commit

Permalink
Merge branch 'dev' into feature/user-destroy-media
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Aug 13, 2024
2 parents eeebde2 + 8e44e6f commit d6e1733
Show file tree
Hide file tree
Showing 103 changed files with 3,500 additions and 2,574 deletions.
15 changes: 15 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# We'd like to place this file to the .config/ folder as well,
# however Codecov doesn't support it yet (or is buggy, see
# https://github.com/codecov/codecov-action/issues/1465)

# Ignore test files themselves in the Codecov report
# see: https://about.codecov.io/blog/should-i-include-test-files-in-code-coverage-calculations/
ignore:
- "spec/**/*"
- "**/*_spec.rb"

# https://docs.codecov.com/docs/commit-status
coverage:
status:
project: off
patch: off
5 changes: 0 additions & 5 deletions .config/.codecov.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .config/.cypress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
e2e: {
// Base URL is set via Docker environment variable
viewportHeight: 1000,
viewportWidth: 1400,
},
};
49 changes: 49 additions & 0 deletions .config/commands/docker.justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prints this help message
[private]
help:
@just --list --justfile {{source_file()}}

# Starts the dev docker containers
@up *args:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose up {{args}}

# Starts the dev docker containers and preseeds the database
[confirm("This will reset all your data in the database locally. Continue? (y/n)")]
up-reseed *args:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
export DB_SQL_PRESEED_URL="https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/20220923120841_mampf.sql"
export UPLOADS_PRESEED_URL="https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/uploads.zip"
docker compose rm --stop --force mampf && docker compose up {{args}}

# Removes the development docker containers
@down:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose down

# Stops the development docker containers (without removing them)
@stop:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose stop

# Puts you into a shell of your desired *development* docker container
@shell name="mampf" shell="bash":
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose exec -it {{name}} bash

# Puts you into a shell of your desired *test* docker container
@shell-test name="mampf" shell="bash":
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/test/
docker compose exec -it {{name}} {{shell}}

# Puts you into the rails console of the dev docker mampf container
@rails-c:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/development/
docker compose exec mampf bundle exec rails c
14 changes: 14 additions & 0 deletions .config/commands/test.justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Prints this help message
[private]
help:
@just --list --justfile {{source_file()}}

# Starts the interactive Cypress test runner UI
cypress:
#!/usr/bin/env bash
cd {{justfile_directory()}}/docker/test
docker compose -f docker-compose.yml -f cypress.yml -f cypress-interactive.yml up --exit-code-from cypress

# Opens Codecov in the default browser
codecov:
xdg-open https://app.codecov.io/gh/MaMpf-HD/mampf
21 changes: 16 additions & 5 deletions .config/eslint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import erb from "eslint-plugin-erb";
import pluginCypress from "eslint-plugin-cypress/flat";
import globals from "globals";

const ignoreFilesWithSprocketRequireSyntax = [
Expand All @@ -22,6 +23,17 @@ const ignoreFilesWithSprocketRequireSyntax = [
"vendor/assets/javascripts/thredded_timeago.js",
];

const ignoreCypressArchivedTests = [
"spec/cypress/e2e/admin_spec.cy.archive.js",
"spec/cypress/e2e/courses_spec.cy.archive.js",
"spec/cypress/e2e/media_spec.cy.archive.js",
"spec/cypress/e2e/search_spec.cy.archive.js",
"spec/cypress/e2e/submissions_spec.cy.archive.js",
"spec/cypress/e2e/thredded_spec.cy.archive.js",
"spec/cypress/e2e/tutorials_spec.cy.archive.js",
"spec/cypress/e2e/watchlists_spec.cy.archive.js",
];

const customGlobals = {
TomSelect: "readable",
bootstrap: "readable",
Expand Down Expand Up @@ -87,16 +99,15 @@ const customGlobals = {

// KaTeX
renderMathInElement: "readable",
};

// We don't have cypress linting yet, as the Cypress ESLint plugin
// doesn't support the new flat config yet
// https://github.com/cypress-io/eslint-plugin-cypress/issues/146
openAnnotationIfSpecifiedInUrl: "readable",
};

export default [
js.configs.recommended,
// Allow linting of ERB files, see https://github.com/Splines/eslint-plugin-erb
erb.configs.recommended,
pluginCypress.configs.recommended,
// Globally ignore the following paths
{
ignores: [
Expand All @@ -107,8 +118,8 @@ export default [
"public/packs-test/",
"public/uploads/",
"public/pdfcomprezzor/",
"spec/cypress/",
...ignoreFilesWithSprocketRequireSyntax,
...ignoreCypressArchivedTests,
],
},
{
Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,39 @@ jobs:
files: ./coverage/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
codecov_yml_path: ./config/codecov.yml

# Cypress end-to-end tests
e2e-tests:
name: e2e (Cypress)
environment: testing
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

# see https://github.com/orgs/MaMpf-HD/packages?repo_name=mampf
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker images
# As the docker-compose.yml file uses contexts like "./../..", we have
# to change the working directory here.
working-directory: docker/test
run: >
docker buildx bake -f ./docker-compose.yml -f ./cypress.yml
-f ./../../.github/workflows/docker-compose-cache.json
- name: Run Cypress tests
working-directory: docker/test
# "cypress run" is defined in the cypress.yml entrypoint
run: docker compose -f ./docker-compose.yml -f ./cypress.yml run cypress
36 changes: 36 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Documentation: https://just.systems/man/en/

# Prints this help message
[private]
help:
@just --list

# Test-related commands
mod test ".config/commands/test.justfile"
# see https://github.com/casey/just/issues/2216
# alias t := test

# Docker-related commands
mod docker ".config/commands/docker.justfile"

# Opens the MaMpf wiki in the default browser
wiki:
#!/usr/bin/env bash
xdg-open https://github.com/MaMpf-HD/mampf/wiki
# Opens the MaMpf pull requests (PRs) in the default browser
prs:
#!/usr/bin/env bash
xdg-open https://github.com/MaMpf-HD/mampf/pulls
# Opens the PR for the current branch in the default browser
pr:
#!/usr/bin/env bash
branchname=$(git branch --show-current)
xdg-open "https://github.com/MaMpf-HD/mampf/pulls?q=is%3Apr+is%3Aopen+head%3A$branchname"
# Opens the MaMpf GitHub code tree at the current branch in the default browser
code branch="":
#!/usr/bin/env bash
branchname={{ if branch == "" {"$(git branch --show-current)"} else {branch} }}
xdg-open https://github.com/MaMpf-HD/mampf/tree/$branchname
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"shopify.ruby-lsp",
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker",
"streetsidesoftware.code-spell-checker-german"
"streetsidesoftware.code-spell-checker-german",
"nefrob.vscode-just-syntax"
]
}
9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"source.fixAll.eslint": "explicit"
},
"eslint.format.enable": true, // use ESLint as formatter
"eslint.experimental.useFlatConfig": true,
// this disables VSCode built-in formatter (instead we want to use ESLint)
"javascript.validate.enable": false,
"eslint.options": {
Expand Down Expand Up @@ -71,7 +70,8 @@
"node_modules/": true,
"pdfcomprezzor/": true,
"coverage/": true,
"solr/": true
"solr/": true,
".docker/": true
},
"files.associations": {
"*.js.erb": "javascript",
Expand Down Expand Up @@ -104,8 +104,9 @@
//////////////////////////////////////
"cSpell.words": [
"commontator",
"factorybot",
"helpdesk",
"katex",
"turbolinks"
],
"rubyLsp.customRubyCommand": "set -o allexport && . ./docker-dummy.env && set +o allexport"
]
}
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ group :test, :development, :docker_development do
gem "factory_bot_rails"
gem "rspec-rails"

gem "cypress-on-rails", "~> 1.0"
gem "simplecov-cobertura"

gem "rspec-github"
Expand Down
Loading

0 comments on commit d6e1733

Please sign in to comment.