-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Resolve name conflict between a local module and the git package's cmd module * Simple unit tests for SemVer 2.0 version numbers * Contributing instructions (including how to run tests locally)
- Loading branch information
Showing
11 changed files
with
192 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,71 @@ | ||
# Contributing to this repo | ||
|
||
## Setup | ||
|
||
### Personal access token (PAT) | ||
|
||
Follow [these](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) instructions to configurate a personal access token. | ||
|
||
Only permissions needed: | ||
- public_repo | ||
|
||
Save the token to a secure location. Click the "Configure SSO" button and "Authorize" if applicable. | ||
|
||
### Config | ||
|
||
```shell | ||
cp config.example.json config.json | ||
|
||
# Add your GitHub username and token | ||
$EDITOR config.json | ||
|
||
# Export the JSON credentials into an environment variable | ||
export CONFIG=$(<config.json) | ||
``` | ||
|
||
## Virtual environment | ||
|
||
### Install dependencies | ||
Instructions for POSIX bash/zsh (see [here](https://docs.python.org/3/library/venv.html) for syntax for other shells): | ||
```shell | ||
python3 -m venv env | ||
source env/bin/activate | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements.txt -r dev-requirements.txt | ||
source env/bin/activate | ||
``` | ||
|
||
## Testing locally | ||
|
||
```shell | ||
PYTHONPATH=hubcap python -m pytest | ||
``` | ||
|
||
## Run in test mode | ||
|
||
```shell | ||
export ENV=test | ||
./cron.sh | ||
``` | ||
|
||
### Optional configuration environment variables | ||
``` | ||
# Default value is the `git-tmp` directory within the current working directory | ||
# This directory will be deleted by default at the end of the run | ||
export GIT_TMP=git-tmp | ||
``` | ||
|
||
### Optional parameters | ||
Preserve commits/build artifacts within the `$GIT_TMP` directory | ||
``` | ||
export ENV=test | ||
./cron.sh --no-cleanup | ||
``` | ||
|
||
## Run in production mode | ||
|
||
**WARNING:** Use with caution -- _will_ modify state. | ||
```shell | ||
export ENV=prod | ||
./cron.sh | ||
``` |
This file contains 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"name": "github_user", | ||
"token": "pe4s0n@l-@cce$$-t0k3n" | ||
}, | ||
"remote": "[email protected]:org/hub.getdbt.com.git", | ||
"remote": "[email protected]:dbt-labs/hub.getdbt.com.git", | ||
"push_branches": true, | ||
"one_branch_per_repo": true | ||
} |
This file contains 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,2 @@ | ||
black==22.6.0 | ||
pytest |
Empty file.
File renamed without changes.
This file contains 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 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 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 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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
import package | ||
|
||
from cmd import * | ||
from git_helper import * | ||
|
||
|
||
def parse_semver_tag(tag): | ||
|
Empty file.
This file contains 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,111 @@ | ||
import pytest | ||
from hubcap.version import is_valid_semver_tag | ||
|
||
|
||
@pytest.fixture | ||
def semver_20_valid(): | ||
"""Valid SemVer 2.0 versions""" | ||
# Most test cases from https://regex101.com/r/Ly7O1x/3/ | ||
return [ | ||
# Begin test cases from https://regex101.com/r/Ly7O1x/3/ | ||
"0.0.4", | ||
"1.2.3", | ||
"10.20.30", | ||
"1.1.2-prerelease+meta", | ||
"1.1.2+meta", | ||
"1.1.2+meta-valid", | ||
"1.0.0-alpha", | ||
"1.0.0-beta", | ||
"1.0.0-alpha.beta", | ||
"1.0.0-alpha.beta.1", | ||
"1.0.0-alpha.1", | ||
"1.0.0-alpha0.valid", | ||
"1.0.0-alpha.0valid", | ||
"1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay", | ||
"1.0.0-rc.1+build.1", | ||
"2.0.0-rc.1+build.123", | ||
"1.2.3-beta", | ||
"10.2.3-DEV-SNAPSHOT", | ||
"1.2.3-SNAPSHOT-123", | ||
"1.0.0", | ||
"2.0.0", | ||
"1.1.7", | ||
"2.0.0+build.1848", | ||
"2.0.1-alpha.1227", | ||
"1.0.0-alpha+beta", | ||
"1.2.3----RC-SNAPSHOT.12.9.1--.12+788", | ||
"1.2.3----R-S.12.9.1--.12+meta", | ||
"1.2.3----RC-SNAPSHOT.12.9.1--.12", | ||
"1.0.0+0.build.1-rc.10000aaa-kk-0.1", | ||
"99999999999999999999999.999999999999999999.99999999999999999", | ||
"1.0.0-0A.is.legal", | ||
# Begin custom test cases | ||
"1.0.3-post1", | ||
"0.8.0-a1", | ||
"0.8.0-b2", | ||
"0.8.0-rc3", | ||
] | ||
|
||
|
||
@pytest.fixture | ||
def semver_20_invalid(): | ||
"""Invalid SemVer 2.0 versions""" | ||
# Most test cases from https://regex101.com/r/Ly7O1x/3/ | ||
return [ | ||
# Begin test cases from https://regex101.com/r/Ly7O1x/3/ | ||
"1", | ||
"1.2", | ||
"1.2.3-0123", | ||
"1.2.3-0123.0123", | ||
"1.1.2+.123", | ||
"+invalid", | ||
"-invalid", | ||
"-invalid+invalid", | ||
"-invalid.01", | ||
"alpha", | ||
"alpha.beta", | ||
"alpha.beta.1", | ||
"alpha.1", | ||
"alpha+beta", | ||
"alpha_beta", | ||
"alpha.", | ||
"alpha..", | ||
"beta", | ||
"1.0.0-alpha_beta", | ||
"-alpha.", | ||
"1.0.0-alpha..", | ||
"1.0.0-alpha..1", | ||
"1.0.0-alpha...1", | ||
"1.0.0-alpha....1", | ||
"1.0.0-alpha.....1", | ||
"1.0.0-alpha......1", | ||
"1.0.0-alpha.......1", | ||
"01.1.1", | ||
"1.01.1", | ||
"1.1.01", | ||
"1.2", | ||
"1.2.3.DEV", | ||
"1.2-SNAPSHOT", | ||
"1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788", | ||
"1.2-RC-SNAPSHOT", | ||
"-1.0.3-gamma+b7718", | ||
"+justmeta", | ||
"9.8.7+meta+meta", | ||
"9.8.7-whatever+meta+meta", | ||
"99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12", | ||
# Begin custom test cases | ||
"1.0.3.post1", | ||
"0.8.0a1", | ||
"0.8.0b2", | ||
"0.8.0rc3", | ||
] | ||
|
||
|
||
def test_regex_valid(semver_20_valid): | ||
for version in semver_20_valid: | ||
assert is_valid_semver_tag(version) | ||
|
||
|
||
def test_regex_invalid(semver_20_invalid): | ||
for version in semver_20_invalid: | ||
assert not is_valid_semver_tag(version) |