-
Notifications
You must be signed in to change notification settings - Fork 6
GitHub Action and GitLab CI/CD Component #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
2509d21
49ad700
39b2fe0
913d6d2
aeda4f6
4479a97
eedf02e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Set up zpretty | ||
| description: > | ||
| Install zpretty so a workflow can run it (for example `zpretty --check`). | ||
|
|
||
| inputs: | ||
| spec: | ||
| description: > | ||
| pip requirement specifier for zpretty: a release such as | ||
| "zpretty==4.0.2", a VCS URL, or "." to install the checked-out source. | ||
| required: false | ||
| default: zpretty | ||
| python-version: | ||
| description: Python version to set up. | ||
| required: false | ||
| default: "3.x" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
|
|
||
| - name: Install zpretty | ||
| shell: bash | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install "${{ inputs.spec }}" | ||
|
|
||
| - name: Report zpretty version | ||
| shell: bash | ||
| run: zpretty --version | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: zpretty action | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| self-test: | ||
| name: Set up zpretty from source and run it | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
ale-rt marked this conversation as resolved.
|
||
|
|
||
| - name: Set up zpretty from this checkout | ||
| uses: ./.github/actions/zpretty | ||
| with: | ||
| spec: . | ||
|
|
||
| - name: Smoke-test the installed zpretty | ||
| shell: bash | ||
| run: zpretty --check zpretty/tests/original/sample_xml.xml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| global-exclude *.pyc __pycache__ pyvenv.cfg | ||
| graft zpretty | ||
| graft zpretty/tests/include-excludes/.git | ||
| recursive-include gitlab *.yml | ||
| include *.cfg *.txt *.md *.in LICENSE Makefile .pre-commit-config.yaml .pre-commit-hooks.yaml tox.ini pyproject.toml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,43 @@ To do so, add the following to your `.pre-commit-config.yaml`: | |
| - id: zpretty | ||
| ``` | ||
|
|
||
| # Continuous integration | ||
|
|
||
| ## GitHub Actions | ||
|
|
||
| This repository ships a composite action that installs `zpretty` so a | ||
| workflow can run it: | ||
|
|
||
| ```yaml | ||
| - uses: actions/checkout@v6 | ||
| - uses: collective/zpretty/.github/actions/zpretty@master | ||
| - run: zpretty --check path/to/file.xml | ||
|
Comment on lines
+153
to
+155
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change of line 147 is wrong.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed v6 is the latest Action. One could think that Microsoft trains their models on the docs of their own services 🤔 The benefit of pointing at the default branch @ale-rt think we should change to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look e.g. at https://github.com/actions/checkout#fetch-only-the-root-files they are pointing to a version. Using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. You mean to pin the currently latest version in the readme, not Want to add a drift test for the readme? |
||
| ``` | ||
|
|
||
| The action takes two optional inputs: `spec`, a pip requirement specifier | ||
| (a release such as `zpretty==4.0.2`, a VCS URL, or `.` to install the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see the reason of checking out a zpretty and then using a spec different from |
||
| checked-out source; defaults to `zpretty`), and `python-version` | ||
| (defaults to `3.x`). | ||
|
|
||
| ## GitLab CI/CD | ||
|
|
||
| For GitLab there is a reusable CI/CD configuration. Include it and extend | ||
| the `.zpretty` job it defines: | ||
|
|
||
| ```yaml | ||
| include: | ||
| - remote: "https://raw.githubusercontent.com/collective/zpretty/master/gitlab/zpretty.gitlab-ci.yml" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree about the use of but that should be explained. |
||
|
|
||
| zpretty: | ||
| extends: .zpretty | ||
| script: | ||
| - zpretty --check path/to/file.xml | ||
| ``` | ||
|
|
||
| Set the `ZPRETTY_SPEC` variable (default `zpretty`) to change the pip | ||
| specifier and `ZPRETTY_PYTHON_VERSION` (default `3`) to pick the Python | ||
| image tag. | ||
|
|
||
| # VSCode extension | ||
|
|
||
| There is a VSCode extension that uses `zpretty`: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Reusable zpretty setup for GitLab CI. Usage: | ||
| # include: | ||
| # - remote: "https://raw.githubusercontent.com/collective/zpretty/<ref>/gitlab/zpretty.gitlab-ci.yml" | ||
| # zpretty: | ||
| # extends: .zpretty | ||
| # variables: { ZPRETTY_SPEC: "zpretty==4.0.2" } # optional | ||
| # script: [zpretty --check path/to/file.xml] | ||
| .zpretty: | ||
| image: "python:$ZPRETTY_PYTHON_VERSION" | ||
| variables: | ||
| ZPRETTY_PYTHON_VERSION: "3" | ||
| ZPRETTY_SPEC: zpretty | ||
| before_script: | ||
| - pip install "$ZPRETTY_SPEC" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GH action looks like: Maybe we should have the same here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned on the Action, I am leaning to remove the pip upgrade, unless you prefer to upgrade it here as well.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no hard preference. |
||
| - zpretty --version | ||
|
Comment on lines
+13
to
+15
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am +0 on this
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Python environment should need to bother us here, because if Pip fails installing zpretty, it probably also fails upgrading itself. |
||
Uh oh!
There was an error while loading. Please reload this page.