kantord / LibreLingo

🐢 🌎 📚 a community-owned language-learning platform
https://librelingo.app
GNU Affero General Public License v3.0
1.96k stars 214 forks source link

Make it easy to run tests locally #2078

Open szabgab opened 2 years ago

szabgab commented 2 years ago

In order to prevent to avoid making the CI fail I run some of the CI tests locally (when I don't forget it). For this I use the following script that takes 30 seconds to run on my computer.

#!/usr/bin/env python
import os

commands = (
    #"black apps --check",
    "black apps",
    "pytest --doctest-modules",
    "pylint $(git ls-files '*.py')",
    "mypy apps",
    "yarn eslint apps/*/src --no-error-on-unmatched-pattern",
)

failed = 0
for cmd in commands:
    print(cmd)
    exit_code = os.system(cmd)
    if exit_code != 0:
        failed += 1

print("==================================")
if failed > 0:
    print(f"FAILED {failed}")
else:
    print("ALL is Good, you can commit now")

I call it check.py

IMHO it would be nice to add this script to the repo to make it easier to maintain. What other tests could I run locally? If you think it is a good idea to add it, where should I put it and how should we call it?

kantord commented 2 years ago

you run it every 30 seconds? that's a lot, no? isn't it enough to run them before you commit? we can add them in a pre-commit hook.

by the way, I think there's a simpler way to go. Right now in the CI we have 2 providers for running pipelines:

There's a tool for running GitHub actions locally using Docker: https://github.com/nektos/act

So, if we migrate everything to GitHub actions, then it will become possible to run the CI locally. In that case I think we can split the actions into 3 parts:

What you are running now, is roughly the everything else part. If we can run GitHub actions locally, and we are able to run just the "everything else" part, then we already have the solution.

The best part is that we'll likely not want to run Cypress and deployment locally, therefore those don't need to be migrated to GitHub actions in order to make this work.

szabgab commented 2 years ago

No, it takes 30 seconds :) I run it before I commit. If I don't forget.