An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
Github Actions (Lab 9)
Setting up
For my CI workflow, I went with Anaconda.
I altered the default YAML to run on push and pull requests on the main branch.
When installing dependencies, the default YAML looks for a environment.yml
file. I don't have that in my project so I set it up to install each dependency individually.
Testing the workflow
After committing the YAML, I noticed that the workflow failed with this reason:
Version 3.1 with arch x64 not found The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
I fixed this by changing the python version to 3.9.5, the version on my local machine.
The workflow then passed successfully.
name: Python Package using Condaon: push: branches: [ main ] pull_request: branches: [ main ]jobs: build-linux: runs-on: ubuntu-latest strategy: max-parallel: 5 steps: - uses: actions/checkout@v2 - name: Set up Python 3.9.5 uses: actions/setup-python@v2 with: python-version: 3.9.5 - name: Add conda to system path run: | # $CONDA is an environment variable pointing to the root of the miniconda directory echo $CONDA/bin >> $GITHUB_PATH - name: Install dependencies run: | conda install black conda install flake8 conda install markdown conda install pygments - name: Lint with flake8 run: | conda install flake8 # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | conda install pytest pytest
Writing a test for another repo
I chose to work on Roman Rezinkin's SSG for this part. I looked through his testing file roman_ssg_util.py
for any functions he may have missed and found create_index_page()
.
After writing a simple test for it that calls the function and checks if the index page file was created, I created a pull request. The workflow Roman had set up passed and it was quickly merged.
def test_create_index_page(): roman_ssg_util.create_index_page("en-US", ["1.html"]) assert os.path.isfile("./index.html") os.remove("index.html")
Outcomes
This lab really showed me how powerful Github Actions can be, especially when reviewing pull requests. It ensures that the pull request adheres to your rules, customizable in the YAML file.
Original Link: https://dev.to/ar/github-actions-lab-9-37d7
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To