From 6b98be3fafc9154cd30ff4622479b45bd34efa9e Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sat, 3 Dec 2022 16:16:22 +0800 Subject: [PATCH 1/4] ci(scripts): add -nr 3 to commitizen commit check when first creating a commit, there won't be any commit ahead of origin/master.. Thus, no commit to check error won't make sense in this case --- scripts/test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test b/scripts/test index ea5a31898..d57bdddc4 100755 --- a/scripts/test +++ b/scripts/test @@ -10,4 +10,4 @@ ${PREFIX}isort --check-only commitizen tests ${PREFIX}flake8 commitizen/ tests/ ${PREFIX}mypy commitizen/ tests/ ${PREFIX}pydocstyle --convention=google --add-ignore=D1,D415 --match-dir='"${REGEX}"' -${PREFIX}commitizen check --rev-range origin/master.. +${PREFIX}commitizen -nr 3 check --rev-range origin/master.. From c22cde65a5459cbf0e1e806832560d0297d6f31a Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sat, 3 Dec 2022 16:18:14 +0800 Subject: [PATCH 2/4] feat(yaml_config): add explicit_start for yaml output generate cz.yaml that comply yamllint --- commitizen/config/yaml_config.py | 4 ++-- tests/test_conf.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/commitizen/config/yaml_config.py b/commitizen/config/yaml_config.py index 503b32ce0..12c323846 100644 --- a/commitizen/config/yaml_config.py +++ b/commitizen/config/yaml_config.py @@ -17,7 +17,7 @@ def __init__(self, *, data: Union[bytes, str], path: Union[Path, str]): def init_empty_config_content(self): with smart_open(self.path, "a") as json_file: - yaml.dump({"commitizen": {}}, json_file) + yaml.dump({"commitizen": {}}, json_file, explicit_start=True) def _parse_setting(self, data: Union[bytes, str]) -> None: """We expect to have a section in cz.yaml looking like @@ -44,6 +44,6 @@ def set_key(self, key, value): parser["commitizen"][key] = value with smart_open(self.path, "w") as yaml_file: - yaml.dump(parser, yaml_file) + yaml.dump(parser, yaml_file, explicit_start=True) return self diff --git a/tests/test_conf.py b/tests/test_conf.py index 746cde240..6e03052c2 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -160,3 +160,13 @@ def test_init_empty_config_content(self, tmpdir): with open(path, "r") as json_file: assert json.load(json_file) == {"commitizen": {}} + + +class TestYamlConfig: + def test_init_empty_config_content(self, tmpdir): + path = tmpdir.mkdir("commitizen").join(".cz.yaml") + yaml_config = config.YAMLConfig(data="{}", path=path) + yaml_config.init_empty_config_content() + + with open(path, "r") as yaml_file: + assert yaml.safe_load(yaml_file) == {"commitizen": {}} From 8813a1837c7f937309f2798448024940b89fb047 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sat, 3 Dec 2022 16:18:46 +0800 Subject: [PATCH 3/4] ci(pre-commit): set linter and test stage to push stage --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 51967aff1..c9ac30095 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,5 +35,6 @@ repos: name: linter and test language: system pass_filenames: false + stage: push entry: ./scripts/test types: [python] From 0c807f311e5f6874a52590248a028ddd1f73b31c Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sat, 3 Dec 2022 16:37:49 +0800 Subject: [PATCH 4/4] ci(github-actions): upgrade github-actions version --- .github/workflows/bumpversion.yml | 2 +- .github/workflows/docspublish.yaml | 4 ++-- .github/workflows/homebrewpublish.yaml | 4 ++-- .github/workflows/pythonpackage.yml | 4 ++-- .github/workflows/pythonpublish.yaml | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index 86f690179..b213c6047 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -12,7 +12,7 @@ jobs: name: "Bump version and create changelog with commitizen" steps: - name: Check out - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}' diff --git a/.github/workflows/docspublish.yaml b/.github/workflows/docspublish.yaml index 4cb3b47c3..98af4ad18 100644 --- a/.github/workflows/docspublish.yaml +++ b/.github/workflows/docspublish.yaml @@ -9,12 +9,12 @@ jobs: publish-documentation: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}' fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/homebrewpublish.yaml b/.github/workflows/homebrewpublish.yaml index 2ff28078b..5e08e16bc 100644 --- a/.github/workflows/homebrewpublish.yaml +++ b/.github/workflows/homebrewpublish.yaml @@ -12,9 +12,9 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 57d8b8d45..0e47a90b9 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -10,11 +10,11 @@ jobs: platform: [ubuntu-20.04, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/pythonpublish.yaml b/.github/workflows/pythonpublish.yaml index e060663ba..5190fb1f1 100644 --- a/.github/workflows/pythonpublish.yaml +++ b/.github/workflows/pythonpublish.yaml @@ -9,12 +9,12 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}' fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies