Skip to content

Commit

Permalink
Modified Pipeline again and updated secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiahuita committed Apr 30, 2024
1 parent 90cc4b8 commit 06d1d54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/weatherDataCollect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check if secrets are empty
run: |
if [ -z "${{ secrets.DOCKER_USERNAME }}" ] || [ -z "${{ secrets.DOCKER_PASSWORD }}" ]; then
echo "One of the secrets is empty!"
else
echo "Secrets are not empty."
fi
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Push Weather Data Collection to Docker Hub
Expand Down
6 changes: 5 additions & 1 deletion web-app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ <h2>Weather Data for {{ weather_data.city }}</h2>
{% else %}
<p>Wind Speed: N/A</p>
{% endif %}
<p>Conditions: {{ weather_data.weather[0].description }}</p>
{% if 'weather' in weather_data and weather_data.weather %}
<p>Conditions: {{ weather_data.weather[0].description }}</p>
{% else %}
<p>Conditions: N/A</p>
{% endif %}
{% elif error %}
<p>{{ error }}</p>
{% endif %}
Expand Down
6 changes: 4 additions & 2 deletions web-app/tests/test_webApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def test_index_post(self):
'temp_kelvin': 298.65,
'temp_celsius': 25.5,
'temp_fahrenheit': 77.9
}
}), patch('requests.post') as mock_post:
},
'weather': [{'description': 'Clear'}]
}), patch('requests.post') as mock_post:
mock_post.return_value.status_code = 200
response = self.app.post('/', data={'city': 'New York', 'temp_unit': 'Celsius'})
self.assertEqual(response.status_code, 200)
self.assertIn(b'New York', response.data)
self.assertIn(b'temp_celsius', response.data)
self.assertIn(b'Clear', response.data)

def test_index_post_not_found(self):
# Test POST request to the index route when weather data is not found
Expand Down

0 comments on commit 06d1d54

Please sign in to comment.