name: Run Python Tests permissions: contents: read # ----------------- # --- Triggers ---- # ----------------- # This section defines when the workflow will run. on: # Run on every push to the 'main' branch push: branches: [ "main", "30-create-tests-and-set-up-a-github-pipeline" ] # Also run on every pull request that targets the 'main' branch pull_request: branches: [ "main" ] # ----------------- # ------ Jobs ----- # ----------------- # A workflow is made up of one or more jobs that can run in parallel or sequentially. jobs: # A descriptive name for your job build-and-test: # Specifies the virtual machine to run the job on. 'ubuntu-latest' is a common and cost-effective choice. runs-on: ubuntu-latest # ----------------- # ----- Steps ----- # ----------------- # A sequence of tasks that will be executed as part of the job. steps: # Step 1: Check out your repository's code # This action allows the workflow to access your code. - name: Check out repository code uses: actions/checkout@v4 # Step 2: Set up the Python environment # This action installs a specific version of Python on the runner. - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' # Use the Python version that matches your project # Step 3: Install project dependencies # Runs shell commands to install the libraries listed in your requirements.txt. - name: Add test dependencies to requirements run: | echo "pytest==8.4.2" >> ./7project/backend/requirements.txt echo "pytest-asyncio==1.2.0" >> ./7project/backend/requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r ./7project/backend/requirements.txt # Step 4: Run your tests! # Executes the pytest command to run your test suite. - name: Run tests with pytest run: pytest working-directory: ./7project/backend