-
Notifications
You must be signed in to change notification settings - Fork 0
Add CI pipeline for unit tests #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b8dd400
Add CI pipeline for unit tests
8282b6b
Simplify CI to single Python 3.13 version
ae12a7f
Add release pipeline, CI-CD docs, and install guide
2234ad8
Pass repository secrets to CI unit test environment
bf2cbaf
Use date-based versioning and embed version in every build
025cd19
Dynamic version from package metadata and promote release pipeline
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Unit tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python 3.13 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| cache: pip | ||
|
|
||
| - name: Generate version | ||
| run: echo "VERSION=$(date +%Y.%m.%d).${{ github.run_number }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Install tox and build | ||
| run: pip install tox build | ||
|
|
||
| - name: Run unit tests | ||
| run: tox -e unit | ||
| env: | ||
| CE_PUBLISHER_BASE: ${{ secrets.CE_PUBLISHER_BASE }} | ||
| CE_TEST_ACCESS_TOKEN: ${{ secrets.CE_TEST_ACCESS_TOKEN }} | ||
| CE_TEST_USER_ID: ${{ secrets.CE_TEST_USER_ID }} | ||
| CE_TEST_CTID: ${{ secrets.CE_TEST_CTID }} | ||
| CE_TEST_CHALLENGE_UUID: ${{ secrets.CE_TEST_CHALLENGE_UUID }} | ||
| CE_TEST_DID_KEY: ${{ secrets.CE_TEST_DID_KEY }} | ||
|
|
||
| - name: Build package | ||
| run: python -m build | ||
| env: | ||
| SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.VERSION }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Build and release | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python 3.13 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| cache: pip | ||
|
|
||
| - name: Generate version | ||
| run: echo "VERSION=$(date +%Y.%m.%d).${{ github.run_number }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Install tox and build | ||
| run: pip install tox build | ||
|
|
||
| - name: Run unit tests | ||
| run: tox -e unit | ||
| env: | ||
| CE_PUBLISHER_BASE: ${{ secrets.CE_PUBLISHER_BASE }} | ||
| CE_TEST_ACCESS_TOKEN: ${{ secrets.CE_TEST_ACCESS_TOKEN }} | ||
| CE_TEST_USER_ID: ${{ secrets.CE_TEST_USER_ID }} | ||
| CE_TEST_CTID: ${{ secrets.CE_TEST_CTID }} | ||
| CE_TEST_CHALLENGE_UUID: ${{ secrets.CE_TEST_CHALLENGE_UUID }} | ||
| CE_TEST_DID_KEY: ${{ secrets.CE_TEST_DID_KEY }} | ||
|
|
||
| - name: Build package | ||
| run: python -m build | ||
| env: | ||
| SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.VERSION }} | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: v${{ env.VERSION }} | ||
| name: v${{ env.VERSION }} | ||
| files: dist/* | ||
| generate_release_notes: true | ||
| prerelease: ${{ github.event_name == 'push' }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # CI/CD | ||
|
|
||
| ## CI pipeline | ||
|
|
||
| The CI pipeline runs automatically on every push to `main` and on every pull request targeting `main`. | ||
|
|
||
| **What it does:** | ||
| - Sets up Python 3.13 | ||
| - Installs `tox` | ||
| - Runs unit tests via `tox -e unit` | ||
|
|
||
| Integration tests (those marked `@pytest.mark.integration`) are excluded from CI because they require a live API environment. | ||
|
|
||
| To run tests locally: | ||
| ``` | ||
| pip install tox | ||
| tox -e unit | ||
| ``` | ||
|
|
||
| ## Release pipeline | ||
|
|
||
| Releases are triggered manually via **Actions → Release → Run workflow** in GitHub. | ||
|
|
||
| **Version format:** `YYYY.MM.DD.<run_number>` — for example, `2026.04.15.42` | ||
|
|
||
| The version is auto-generated from the date and the pipeline run number. There is no version field to manually edit and no tags to push. | ||
|
|
||
| **What the pipeline does:** | ||
| 1. Generates the version from the current date and run number | ||
| 2. Runs unit tests — if they fail, the release is aborted | ||
| 3. Builds the package (`.whl` and `.tar.gz`) with the generated version embedded | ||
| 4. Creates a GitHub Release tagged `v<version>` with both files attached and auto-generated release notes | ||
|
|
||
| **How to cut a release:** | ||
|
|
||
| Go to the repository on GitHub → Actions → Release → Run workflow → Run workflow. | ||
|
|
||
| That's it. The pipeline takes care of the rest. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Installation | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Python 3.10 or later | ||
| - `pip` | ||
|
|
||
| ## Install from a release | ||
|
|
||
| 1. Go to the [Releases page](../../releases) and download the `.whl` file from the latest release. | ||
|
|
||
| 2. Install it with pip: | ||
| ``` | ||
| pip install ce_cli-<version>-py3-none-any.whl | ||
| ``` | ||
|
|
||
| 3. Verify the installation: | ||
| ``` | ||
| ce --help | ||
| ``` | ||
|
|
||
| ## Install from source | ||
|
|
||
| ``` | ||
| git clone https://github.com/CredentialEngine/ce-cli.git | ||
| cd ce-cli | ||
| pip install -e . | ||
| ``` | ||
|
|
||
| ## Upgrading | ||
|
|
||
| Download the `.whl` from the new release and re-run: | ||
| ``` | ||
| pip install --upgrade ce_cli-<version>-py3-none-any.whl | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| __version__ = "0.1.0" | ||
| from importlib.metadata import version, PackageNotFoundError | ||
|
|
||
| try: | ||
| __version__ = version("ce-cli") | ||
| except PackageNotFoundError: | ||
| __version__ = "0.0.0+unknown" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.