diff --git a/.github/workflows/installation.yaml b/.github/workflows/installation.yaml index 70dfb2000..c8d4ca6a7 100644 --- a/.github/workflows/installation.yaml +++ b/.github/workflows/installation.yaml @@ -9,44 +9,41 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: + - uses: actions/checkout@v2 + with: fetch-depth: 1 - - name: Output Python version - id: python-version - run: | - echo "::set-output name=python-version::$(cat .python-version)" - - name: Cache pyenv versions - uses: actions/cache@v2.1.1 - id: cached-pyenvs - with: - path: /opt/hostedtoolcache/pyenv_root - key: ${{ runner.os }}-pyenv - - name: Install pyenv versions - uses: gabrielfalcao/pyenv-action@v9 - with: - default: ${{ steps.python-version.outputs.python-version }} - # if: steps.cached-pyenvs.outputs.cache-hit != 'true' - - name: Install Poetry - run: | - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - source $HOME/.poetry/env - pyenv install -s - poetry config virtualenvs.in-project true - poetry env info - poetry env use `cat .python-version` - - name: Cache dependencies - uses: actions/cache@v2.1.1 - id: cached-poetry-dependencies - with: - path: .venv - key: venv-${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} - - name: Install dependencies - run: | - source $HOME/.poetry/env - poetry install - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - - name: Run tests - run: | - source $HOME/.poetry/env - poetry run pytest + - name: Output Python version + id: python-version + run: | + echo "::set-output name=python-version::$(cat .python-version)" + - name: Cache pyenv versions + uses: actions/cache@v2.1.1 + id: cached-pyenvs + with: + path: /opt/hostedtoolcache/pyenv_root + key: ${{ runner.os }}-pyenv + - name: Install pyenv versions + uses: gabrielfalcao/pyenv-action@v9 + with: + default: ${{ steps.python-version.outputs.python-version }} + # if: steps.cached-pyenvs.outputs.cache-hit != 'true' + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + pyenv install -s + poetry config virtualenvs.in-project true + poetry env info + poetry env use `cat .python-version` + - name: Cache dependencies + uses: actions/cache@v2.1.1 + id: cached-poetry-dependencies + with: + path: .venv + key: venv-${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + - name: Install dependencies + run: | + poetry install + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + - name: Run tests + run: | + poetry run pytest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a1b939f87..4264a1a4a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,14 +2,14 @@ name: Run Tests on: push: paths-ignore: - - 'docs/**' - - '*.md' - - Makefile + - "docs/**" + - "*.md" + - Makefile pull_request: paths-ignore: - - 'docs/**' - - '*.md' - - Makefile + - "docs/**" + - "*.md" + - Makefile branches: - main @@ -22,7 +22,7 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@master with: - concurrent_skipping: 'same_content' + concurrent_skipping: "same_content" paths_ignore: '["**/README.md", "**/docs/**", "CHANGELOG.md"]' do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' @@ -48,12 +48,12 @@ jobs: id: cached-poetry with: path: ~/.local - key: poetry-${{ runner.os }}-1.1.7a-python-${{ steps.setup-python.outputs.python-version }} + key: poetry-${{ runner.os }}-1.1.13-python-${{ steps.setup-python.outputs.python-version }} - name: Install and configure Poetry - uses: snok/install-poetry@v1.1.8 + uses: snok/install-poetry@v1.3.1 if: steps.cached-poetry.outputs.cache-hit != 'true' with: - version: 1.1.7 + version: 1.1.13 virtualenvs-create: true virtualenvs-in-project: true - name: Initialize Poetry @@ -128,37 +128,37 @@ jobs: name: Run Unit Tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - uses: actions/setup-python@v2.1.3 - id: setup-python - with: - python-version: ${{ needs.setup_build.outputs.python-version }} - architecture: x64 - - name: Set up root + dependencies cache - uses: actions/cache@v2 - id: cached-project - with: - path: .venv - key: ".venv-${{ runner.os }}-\ - python-${{ steps.setup-python.outputs.python-version }}-\ - ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}" - - name: Run tests - run: | - source .venv/bin/activate - pytest -T unit -n 6 \ - --cov=servo --cov-config=setup.cfg --doctest-modules \ - --cov-report=term-missing:skip-covered \ - --cov-report=xml:artifacts/coverage.xml --cov-report=html:artifacts/coverage-html \ - --junitxml=artifacts/report.xml --html=artifacts/report.html \ - --self-contained-html - - uses: actions/upload-artifact@v2 - with: - name: test-reports - path: artifacts/ - - name: Test CLI entrypoints - run: | - source .venv/bin/activate - servo version + - uses: actions/checkout@master + - uses: actions/setup-python@v2.1.3 + id: setup-python + with: + python-version: ${{ needs.setup_build.outputs.python-version }} + architecture: x64 + - name: Set up root + dependencies cache + uses: actions/cache@v2 + id: cached-project + with: + path: .venv + key: ".venv-${{ runner.os }}-\ + python-${{ steps.setup-python.outputs.python-version }}-\ + ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}" + - name: Run tests + run: | + source .venv/bin/activate + pytest -T unit -n 6 \ + --cov=servo --cov-config=setup.cfg --doctest-modules \ + --cov-report=term-missing:skip-covered \ + --cov-report=xml:artifacts/coverage.xml --cov-report=html:artifacts/coverage-html \ + --junitxml=artifacts/report.xml --html=artifacts/report.html \ + --self-contained-html + - uses: actions/upload-artifact@v2 + with: + name: test-reports + path: artifacts/ + - name: Test CLI entrypoints + run: | + source .venv/bin/activate + servo version integration: name: Run Integration Tests @@ -176,57 +176,57 @@ jobs: github.event_name == 'pull_request' || contains(github.event.head_commit.message, '#test:integration')) steps: - - uses: actions/checkout@master - - uses: actions/setup-python@v2.1.3 - id: setup-python - with: - python-version: ${{ needs.setup_build.outputs.python-version }} - architecture: x64 - - name: Install Vegeta - run: | - wget https://github.com/tsenart/vegeta/releases/download/v12.8.4/vegeta_12.8.4_linux_amd64.tar.gz - tar xfz vegeta_12.8.4_linux_amd64.tar.gz - sudo mv vegeta /usr/local/bin/vegeta - - name: Install Kubectl - # Note: pin to v1.23.6 - run: | - mkdir -p ${{ github.workspace }}/bin - curl -o ${{ github.workspace }}/bin/kubectl -LO "https://dl.k8s.io/release/v1.23.6/bin/linux/amd64/kubectl" - echo "${{ github.workspace }}/bin" >> $GITHUB_PATH - chmod +x ${{ github.workspace }}/bin/kubectl - - name: Set up root + dependencies cache - uses: actions/cache@v2 - id: cached-project - with: - path: .venv - key: ".venv-${{ runner.os }}-\ - python-${{ steps.setup-python.outputs.python-version }}-\ - ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}" - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - name: Create tests/kubeconfig - run: | - mkdir ~/.kube - echo "$KUBE_CONFIG_DATA" | base64 --decode > $HOME/.kube/config - kubectl config view --minify --flatten > tests/kubeconfig - shell: bash - env: - KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} - - name: Install AWS IAM Authenticator - uses: prepor/action-aws-iam-authenticator@master - - name: Run integration tests - run: | - source .venv/bin/activate - pytest -n 8 \ - -T integration --verbose --durations=0 --durations-min=5 - - uses: actions/upload-artifact@v2 - with: - name: integration-test-logs - path: logs/ + - uses: actions/checkout@master + - uses: actions/setup-python@v2.1.3 + id: setup-python + with: + python-version: ${{ needs.setup_build.outputs.python-version }} + architecture: x64 + - name: Install Vegeta + run: | + wget https://github.com/tsenart/vegeta/releases/download/v12.8.4/vegeta_12.8.4_linux_amd64.tar.gz + tar xfz vegeta_12.8.4_linux_amd64.tar.gz + sudo mv vegeta /usr/local/bin/vegeta + - name: Install Kubectl + # Note: pin to v1.23.6 + run: | + mkdir -p ${{ github.workspace }}/bin + curl -o ${{ github.workspace }}/bin/kubectl -LO "https://dl.k8s.io/release/v1.23.6/bin/linux/amd64/kubectl" + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + chmod +x ${{ github.workspace }}/bin/kubectl + - name: Set up root + dependencies cache + uses: actions/cache@v2 + id: cached-project + with: + path: .venv + key: ".venv-${{ runner.os }}-\ + python-${{ steps.setup-python.outputs.python-version }}-\ + ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}" + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Create tests/kubeconfig + run: | + mkdir ~/.kube + echo "$KUBE_CONFIG_DATA" | base64 --decode > $HOME/.kube/config + kubectl config view --minify --flatten > tests/kubeconfig + shell: bash + env: + KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} + - name: Install AWS IAM Authenticator + uses: prepor/action-aws-iam-authenticator@master + - name: Run integration tests + run: | + source .venv/bin/activate + pytest -n 8 \ + -T integration --verbose --durations=0 --durations-min=5 + - uses: actions/upload-artifact@v2 + with: + name: integration-test-logs + path: logs/ system: name: Run System Tests @@ -244,72 +244,72 @@ jobs: github.event_name == 'pull_request' || contains(github.event.head_commit.message, '#test:system')) steps: - - uses: actions/checkout@master - - uses: actions/setup-python@v2.1.3 - id: setup-python - with: - python-version: ${{ needs.setup_build.outputs.python-version }} - architecture: x64 - - name: Set up Poetry cache - uses: actions/cache@v2 - id: cached-poetry - with: - path: ~/.local - key: poetry-${{ runner.os }}-1.1.7a-python-${{ steps.setup-python.outputs.python-version }} - - name: Ensure Poetry is on GITHUB_PATH - run: | - echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Set up root + dependencies cache - uses: actions/cache@v2 - id: cached-project - with: - path: .venv - key: ".venv-${{ runner.os }}-\ - python-${{ steps.setup-python.outputs.python-version }}-\ - ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}" - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - name: Create tests/kubeconfig - run: | - mkdir ~/.kube - echo "$KUBE_CONFIG_DATA" | base64 --decode > $HOME/.kube/config - kubectl config view --minify --flatten > tests/kubeconfig - shell: bash - env: - KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} - - name: Fix permissions - run: | - if [ -d /home/runner/.kube ]; then - sudo chown -R runner:docker /home/runner/.kube - else - mkdir /home/runner/.kube - fi - sudo chown runner:docker tests/kubeconfig - - name: Rename EKS cluster to eks - run: | - kubectl config rename-context \ - --kubeconfig=tests/kubeconfig \ - kubetest eks - - name: Create kind cluster - uses: helm/kind-action@v1.2.0 - with: - cluster_name: kind - - name: Display kind kubeconfig - run: kind get clusters && kind get kubeconfig --name kind - - name: Merge kind kubeconfig - run: kind export kubeconfig --name kind --kubeconfig tests/kubeconfig - - name: Install AWS IAM Authenticator - uses: prepor/action-aws-iam-authenticator@master - - name: Run system tests - run: | - source .venv/bin/activate - pytest -n 6 \ - -T system --verbose --durations=0 --durations-min=5 - - uses: actions/upload-artifact@v2 - with: - name: system-test-logs - path: logs/ + - uses: actions/checkout@master + - uses: actions/setup-python@v2.1.3 + id: setup-python + with: + python-version: ${{ needs.setup_build.outputs.python-version }} + architecture: x64 + - name: Set up Poetry cache + uses: actions/cache@v2 + id: cached-poetry + with: + path: ~/.local + key: poetry-${{ runner.os }}-1.1.13-python-${{ steps.setup-python.outputs.python-version }} + - name: Ensure Poetry is on GITHUB_PATH + run: | + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Set up root + dependencies cache + uses: actions/cache@v2 + id: cached-project + with: + path: .venv + key: ".venv-${{ runner.os }}-\ + python-${{ steps.setup-python.outputs.python-version }}-\ + ${{ hashFiles('**/poetry.lock', 'servo/**/*.py') }}" + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + - name: Create tests/kubeconfig + run: | + mkdir ~/.kube + echo "$KUBE_CONFIG_DATA" | base64 --decode > $HOME/.kube/config + kubectl config view --minify --flatten > tests/kubeconfig + shell: bash + env: + KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} + - name: Fix permissions + run: | + if [ -d /home/runner/.kube ]; then + sudo chown -R runner:docker /home/runner/.kube + else + mkdir /home/runner/.kube + fi + sudo chown runner:docker tests/kubeconfig + - name: Rename EKS cluster to eks + run: | + kubectl config rename-context \ + --kubeconfig=tests/kubeconfig \ + kubetest eks + - name: Create kind cluster + uses: helm/kind-action@v1.2.0 + with: + cluster_name: kind + - name: Display kind kubeconfig + run: kind get clusters && kind get kubeconfig --name kind + - name: Merge kind kubeconfig + run: kind export kubeconfig --name kind --kubeconfig tests/kubeconfig + - name: Install AWS IAM Authenticator + uses: prepor/action-aws-iam-authenticator@master + - name: Run system tests + run: | + source .venv/bin/activate + pytest -n 6 \ + -T system --verbose --durations=0 --durations-min=5 + - uses: actions/upload-artifact@v2 + with: + name: system-test-logs + path: logs/ diff --git a/README.md b/README.md index 615c78e6a..ea4c7f70a 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ any Python package management system should work. * Clone the repo: `git clone git@github.com:opsani/servox` * Install required Python: `cd servox && pyenv install` -* Install Poetry: `curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | - python` +* Install Poetry: `curl -sSL https://install.python-poetry.org | python3 -` +* Add Poetry to your path: `echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> ~/.zshrc` * Link Poetry with pyenv version: ``poetry env use `cat .python-version` `` * Install dependencies: `poetry install` * Activate the venv: `poetry shell` @@ -394,15 +394,18 @@ entries in the `pyproject.toml` file under the `[tool.poetry.plugins."servo.connectors"]` stanza. If you're writing your own connector in an external package, you need to include + ```yaml [tool.poetry.plugins."servo.connectors"] "my_connector" = "my_project.foo:MyConnector" ``` + in your `pyproject.toml` to add your connector as an entry point. -and you _must_ name your connector `class MyConnector(servo.BaseConnector):` to have it discoverable. +and you *must* name your connector `class MyConnector(servo.BaseConnector):` to have it discoverable. Discovery is performed via the `servo.connector:_name_for_connector_class()` function. It matches the `My` in the connector class name to the top level connector key in the `servo.yaml`. So, for example, your `servo.yaml` could be as follows: + ```yaml ... my: