harperreed / hass-firststreet

FirstStreet Integration for Home Assistant
MIT License
0 stars 0 forks source link

sweep: add github action to run tests suite on pr and merge #4

Closed harperreed closed 1 month ago

harperreed commented 1 month ago

Add GitHub Action for running test suite on PR and merge

Description:

Implement a GitHub Action workflow to automatically run the test suite when a pull request is opened or updated, and when code is merged into the main branch.

Tasks:

Test:

Additional tasks:

sweep-ai[bot] commented 1 month ago
Sweeping

Search Results

Response

To address your request for adding a GitHub Action to run the test suite on PR and merge, as well as updating the README with a status badge, I'll make the following changes:

  1. Let's create a new file named .github/workflows/test.yml to set up the GitHub Action workflow:

.github/workflows/test.yml

--- 
+++ 
@@ -1 +1,29 @@
+name: Test

+on:
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ main ]
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.9, "3.10", "3.11"]
+
+    steps:
+    - uses: actions/checkout@v3
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v4
+      with:
+        python-version: ${{ matrix.python-version }}
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install pytest
+        pip install -r requirements.txt
+    - name: Run tests
+      run: |
+        pytest custom_components/firststreet/test_firststreet_api.py

This workflow will:

  1. Now, let's update the README.md file to include a badge for the test workflow status:

README.md

--- 
+++ 
@@ -1,3 +1,5 @@
 # FirstStreet Integration for Home Assistant 🌍💧🔥

+[![Test](https://github.com/harperreed/hass-firststreet/actions/workflows/test.yml/badge.svg)](https://github.com/harperreed/hass-firststreet/actions/workflows/test.yml)
+
 Welcome to the **FirstStreet Integration for Home Assistant**! This project enables users to monitor risk factors associated with environmental conditions such as flooding, fires, heatwaves, winds, and air quality, all based on property location. The data is sourced directly from the FirstStreet API.

These changes will implement the GitHub Action to run the test suite on PR and merge, and add a badge to the README showing the status of the test workflow.

To verify that the GitHub Action runs successfully:

  1. Commit and push these changes to your repository.
  2. Open a new pull request or update an existing one.
  3. Check the "Actions" tab in your GitHub repository to see if the workflow runs automatically.
  4. Merge a pull request to the main branch and verify that the workflow runs on the merge as well.

The custom_components/firststreet/test_firststreet_api.py file is explicitly included in the test command in the GitHub Actions workflow, ensuring it will be run as part of the test suite.

Note: The workflow assumes that there's a requirements.txt file in the root of your repository. If you don't have one, you should create it and list all the dependencies required for your project. Based on the files we've seen, it should at least include:

requests
voluptuous
homeassistant

If you need to add or modify the requirements.txt file, let me know, and I can help you with that as well.

Continue the conversation with Sweep here: https://app.sweep.dev/c/94fc2afc-77c7-4c3d-b80b-9ef056aa38bd.

:book: For more information on how to use Sweep, please read our documentation.

Tracking ID: 68ef6f5c4a