diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index f59d089..f99c1ec 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -1,8 +1,58 @@ name: GitHub Actions AWS connection run-name: ${{ github.actor }} triggered the Github actions -on: [push] + +on: + pull_request: + branches: + - main # Trigger on PR to the 'main' branch (adjust to your target branch) + push: + branches: + - main # Runs on push to main branch only (for Explore-GitHub-Actions) jobs: + lint: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' # Ensure linting only runs for PR events + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Python (for linting tools like flake8, black, yamllint) + uses: actions/setup-python@v2 + with: + python-version: '3.x' # Adjust based on your Python version + + - name: Install linting dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 black yamllint # Install your linting tools + + - name: Run Linting (Python files, YAML files) + run: | + ./test/lint.sh # Run your custom lint script from the test folder + + unit-test: + runs-on: ubuntu-latest + needs: lint # Ensures linting passes before running tests + if: github.event_name == 'pull_request' # Ensure unit tests only run for PR events + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Python (for unit testing) + uses: actions/setup-python@v2 + with: + python-version: '3.x' # Adjust as needed + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt # Adjust based on your setup + + - name: Run unit tests + run: | + pytest test/ # Run your tests from the 'test' folder + Explore-GitHub-Actions: runs-on: ubuntu-latest steps: @@ -42,3 +92,4 @@ jobs: sam deploy --config-file samconfig.toml --config-env default --resolve-s3 --no-confirm-changeset --no-fail-on-empty-changeset - run: echo "This job's status is ${{ job.status }}." + diff --git a/README.md b/README.md index 2bad204..9cfc085 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # API -## How to run the API for testing +## How to Run the API for Testing ### Installing AWS and SAM - Install the AWS CLI and configure your credentials. (We did this in class, but if needed, the process is detailed [here](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/prerequisites.html)). diff --git a/tests/.pylintrc b/tests/.pylintrc new file mode 100644 index 0000000..95863f2 --- /dev/null +++ b/tests/.pylintrc @@ -0,0 +1,37 @@ +[MASTER] +# Set the Python version +py-version=3.13 + +[MESSAGES CONTROL] +disable= + missing-docstring, + invalid-name, + too-few-public-methods, + too-many-arguments, + too-many-locals, + too-many-branches, + too-many-statements, + too-many-instance-attributes, + duplicate-code + +[BASIC] +good-names=i,j,k,x,y,z,_ + +[FORMAT] +# Set max line length to a loose standard +max-line-length=150 + +[DESIGN] +# Allow higher complexity before warnings +max-attributes=10 +max-args=10 +max-locals=20 +max-returns=10 +max-branches=15 +max-statements=50 + +[TYPECHECK] +disable= + no-member, + no-self-use +