-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a basic continuous integration process (#3)
* Create a basic continuous integration setup * Move .env file creation back to test setup * Run system tests in a shell script * Add CI badge to README * Remove unused test code * Update shell system tests * Remove unused tests for now * Clean up workflow file * Install plugin from local * Pluralize test * Remove build on push for this branch This was really just here for debugging while creating an initial workflow. * Remove pytest config since we're not using it
- Loading branch information
Showing
4 changed files
with
151 additions
and
3 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,68 @@ | ||
# Heavily based on the Poetry main Github Actions workflow | ||
# https://github.com/python-poetry/poetry/blob/1.2.0a1/.github/workflows/main.yml | ||
|
||
name: "CI" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
tests: | ||
name: ${{ matrix.os }} / ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }}-latest | ||
strategy: | ||
matrix: | ||
os: [Ubuntu, MacOS] | ||
python-version: [3.6, 3.7, 3.8, 3.9] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Get full Python version | ||
id: full-python-version | ||
shell: bash | ||
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") | ||
|
||
- name: Install poetry | ||
shell: bash | ||
run: curl -sL https://raw.githubusercontent.com/python-poetry/poetry/1.2.0a1/install-poetry.py | python - -y --preview | ||
|
||
- name: Update PATH | ||
shell: bash | ||
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
|
||
- name: Configure poetry | ||
shell: bash | ||
run: poetry config virtualenvs.in-project true | ||
|
||
- name: Set up cache | ||
uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Ensure cache is healthy | ||
if: steps.cache.outputs.cache-hit == 'true' | ||
shell: bash | ||
run: timeout 10s poetry run pip --version || rm -rf .venv | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: poetry install --no-root | ||
|
||
- name: Install poetry-dotenv-plugin | ||
shell: bash | ||
run: poetry plugin add "$GITHUB_WORKSPACE" | ||
|
||
- name: Run system tests | ||
shell: bash | ||
run: tests/test_system.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
This file was deleted.
Oops, something went wrong.
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,81 @@ | ||
#!/usr/bin/env bash | ||
|
||
function create_dotenv_file() { | ||
# Setup .env file so the plugin can do its job | ||
echo "export MY_ENV_VAR='foo'" > .env | ||
} | ||
|
||
function delete_dotenv_file() { | ||
# Tear down .env file since we no longer need it | ||
rm -f .env | ||
} | ||
|
||
function test_end_to_end_system_with_default_dotenv_file() { | ||
# Setup | ||
local expected | ||
expected='foo' | ||
create_dotenv_file | ||
|
||
local output | ||
output=$(poetry run python -c "import os; print(os.environ['MY_ENV_VAR'])") | ||
|
||
# Cleanup | ||
delete_dotenv_file | ||
|
||
if [ "$expected" = "$output" ]; then | ||
printf "test_end_to_end_system_with_default_dotenv_file: PASSED\n" | ||
else | ||
printf "Expected '$expected', but got '%s'.\n" "$output" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function test_end_to_end_system_with_dotenv_location_override() { | ||
# Setup | ||
local expected | ||
expected='bar' | ||
local new_dotenv_path | ||
new_dotenv_path="$PWD/tests/tmp" | ||
create_dotenv_file | ||
|
||
# Override the file that was just created | ||
mkdir -p "$new_dotenv_path" && echo "export MY_ENV_VAR='bar'" > "$new_dotenv_path/.env" | ||
|
||
local output | ||
output=$(export POETRY_DOTENV_LOCATION="$new_dotenv_path/.env" && poetry run python -c "import os; print(os.environ['MY_ENV_VAR'])") | ||
|
||
# Cleanup | ||
rm -rf "$new_dotenv_path" | ||
delete_dotenv_file | ||
|
||
if [ "$expected" = "$output" ]; then | ||
printf "test_end_to_end_system_with_dotenv_location_override: PASSED\n" | ||
else | ||
printf "Expected '$expected', but got '%s'.\n" "$output" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function test_end_to_end_system_without_loading_dotenv_file() { | ||
# Setup | ||
local expected | ||
expected='Nonexistent Variable' | ||
create_dotenv_file | ||
|
||
local output | ||
output=$(export POETRY_DONT_LOAD_ENV=true && poetry run python -c "import os; print(os.environ.get('MY_ENV_VAR', '$expected'))") | ||
|
||
# Cleanup | ||
delete_dotenv_file | ||
|
||
if [ "$expected" = "$output" ]; then | ||
printf "test_end_to_end_system_without_loading_dotenv_file: PASSED\n" | ||
else | ||
printf "Expected '$expected', but got '%s'.\n" "$output" | ||
exit 1 | ||
fi | ||
} | ||
|
||
test_end_to_end_system_with_default_dotenv_file | ||
test_end_to_end_system_with_dotenv_location_override | ||
test_end_to_end_system_without_loading_dotenv_file |