【lunar-Ci】今日诸事不宜!
你是否有过这样的经历,明明合并代码之前通过了所有测试,但是上线之后服务就炸了?
这是因为你的测试不够全面。在Librian幼女娱乐中心(这是个公司),合并代码之前得先检查黄历,如果黄历说诸事不宜,那就不能合并。
使用方法
你只需要为你的GitHub仓库新建一个Action,设置为在收到PR的时候进行单元测试就可以了。
之后所有的PR提交的时候,就会自动对黄历进行测试,从而阻止仓库维护者在诸事不宜的那天合并代码。
Action的参考代码长这样——
name: CI
on:
push:
branches: [ slave ]
pull_request:
branches: [ slave ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2.2.2
with:
python-version: 3.9
- name: Install dependencies
run: pip install lunar_test
- name: lunar_test
run: python -m unittest lunar_test
对了,虽然这是一个Python仓库,但这个Action和仓库语言没有关系,大家都可以用。
本地测试
你也可以使用lunar_test来测试你的本地代码,也只要先pip install lunar_test,然后在测试脚本里加上——
python -m unittest lunar_test
这样就好了,测试代码从来没有这么方便!
Metadata
Release files for lunar-test 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lunar_test-0.0.5.tar.gz | 2.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lunar_test-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.7 kB
Release files / lunar_test-0.0.5.tar.gz
| Download URL | lunar_test-0.0.5.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cf6d4b0b451925181b4a8bf8b5273e454a302e0ca31831de9fe7925dc1c9c21
|
|
BLAKE2b-256 checksum How to use checksums |
308da7eb3383b4e64b21b71c62e6efcc22e692a51b0f529dd5335d12dac6eb73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
|
Release files / lunar_test-0.0.5-py3-none-any.whl
| Download URL | lunar_test-0.0.5-py3-none-any.whl |
|---|---|
| Size | 2.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a8a4ad71c7f4bd2052a764bc20127d02932f01e63aa526e0a05c9d1b799bdeb
|
|
BLAKE2b-256 checksum How to use checksums |
ca0df1f91ef1d507488d88c44af7c259e97d4d4b2eff8c0b801af9b85bd25738
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
|