Update to Contributor guide #319
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
| # yamllint disable rule:line-length | |
| --- | |
| name: lint-and-test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read # This is required for actions/checkout | |
| id-token: write # This is required for OIDC authentication with AWS | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| #---------------------------------------------- | |
| # check-out repo and set-up python | |
| #---------------------------------------------- | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up python | |
| id: setup-python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| #---------------------------------------------- | |
| # ----- install & configure poetry ----- | |
| #---------------------------------------------- | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| version: 1.7.1 | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| #---------------------------------------------- | |
| # load cached venv if cache exists | |
| #---------------------------------------------- | |
| - name: Load cached venv | |
| id: cached-poetry-dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .venv | |
| key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
| #---------------------------------------------- | |
| # Retrieve temporary AWS credentials | |
| #---------------------------------------------- | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v3 | |
| with: | |
| role-to-assume: arn:aws:iam::166659698090:role/githubactions | |
| role-session-name: ghasession | |
| aws-region: us-east-1 | |
| #---------------------------------------------- | |
| # install dependencies | |
| #---------------------------------------------- | |
| - name: Install python dependencies | |
| if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
| run: poetry install --no-interaction --no-root --with test | |
| - name: Install Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| - name: Setup Graphviz | |
| uses: ts-graphviz/setup-graphviz@v1 | |
| - name: Mock ssh file | |
| run : | |
| touch id_rsa.pub | |
| chmod 777 id_rsa.pub | |
| #---------------------------------------------- | |
| # Run static linters | |
| #---------------------------------------------- | |
| - name: Check black formatting | |
| run: | | |
| poetry run black --check -v modules | |
| #---------------------------------------------- | |
| # add terravision to PATH | |
| #---------------------------------------------- | |
| - name: Run tests after adding terravision to path | |
| run: | | |
| export PATH=$PATH:$(pwd) | |
| rm -rf ~/.terravision | |
| poetry run terravision --version | |
| poetry run pytest tests -v |