--I have a Github account, but I haven't published anything ――I sometimes want a general-purpose text check tool, but I didn't really want it, so let's make it and publish it! ――I heard that the next company uses CircleCI --There is also a free plan, so let's use it! ――I will write down the points that I suffered when doing the above.
[Err file path]/Users/xxxx/Documents/test.txt
[Err]Date format does't conform to rules: 2016/2/29 (Monday) 23:59
[Err]Date format does't conform to rules: 2016/2/29 (Month) 23:59
[Err]Date format does't conform to rules(NG list): \n2/29 (Monday) 23:59
[Err]2016/2/30 isn't exist: 2016/2/30 (Tue) 23:59
――I wanted to check various texts in the future, so I named it text_
broadly.
――I will put the conclusion --The test code is also included in TensorFlow published by Google in the world, so I decided that it is okay to put it in. ――As I will describe later, when you want to test with CircleCI, it seems to be troublesome if it is not in the project, so you have to put it in
--Select pytest. ――I was worried about unittest, but when I asked an experienced Python person, it was intuitively easy to understand, so I chose pytest. It's a simple tool, so you don't have to get lost at this point, and you can wrap it around long ones.
――Conclusion I made it like this
tree .
.
├── tests #Test related
│ ├── conftest.py
│ └── test_text_verifier.py
├── textverifier #Main module related
│ ├── config.yaml
│ ├── pattern.yaml
│ └── text_verifier.py
└── verify_text.py #Existence that only executes
--It's a unit test, but I used it as a reference! : Directory structure when writing tests with Python 3 standard unittest
--The conclusion is that I created conftest.py
(which is executed as a pre-process for the entire test) and described the process to pass the relative path of the module directory.
--Reference
-Import by directly specifying the directory path
-Introduction to pytest --Notes from fighting IT engineers
--In the above file hierarchy, I imported the module as follows
from text_verifier import TextVerifier
But such an error
ImportError while importing test module 'xxx'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_text_verifier.py:5: in <module>
from text_verifier import TextVerifier
E ModuleNotFoundError: No module named 'text_verifier'
--So, I wrote conftest.py
under the test directory as follows.
conftest.py
import sys
import os
sys.path.append(os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../textverifier/"))
config.yml
in the project on GitHub side
--Install Docker & CicleCI locally and repeat the verification test of the created config.yml
--Push config.yml
to GitHub
--If you push it, it will be executed on the CicleCI side.
--By the way, the final config.yml
looks like this
version: 2
jobs:
build:
docker:
- image: circleci/python:latest
steps:
- checkout
- run:
command: |
sudo pip install pipenv
pipenv install
pipenv run pip install pyyaml
pipenv run pip install pytest
pipenv run pytest
--This is the readme on GitHub
--Create a state where an error occurs once in the local test --push! & Run! (Failed properly!) --The error was the same as the local error, and it became FAILED there. --Batch was also FAILED
--As for the tool, I noticed it after making it, but there was also a convenient one called textlint ... I wanted to check the format pattern match for this tool. So it's okay, but I felt that the validity check was good with textlint ――Because I've been an uncle Jenkins for a long time, it was quite meaningful just to know CircleCI's glue! I was used to putting the configuration file (execution shell etc.) on the server side, so it was fresh to put it on the repository side (Is GitHub Actions the same?) ――Since it's still the starting line, I'd like to play with CircleCI in particular ... ――Next, I want to make something that can be published on PyPI.