Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 19, 2021 03:42 pm GMT

Github Actions (Lab 9)

Setting up

For my CI workflow, I went with Anaconda.
Image description

I altered the default YAML to run on push and pull requests on the main branch.
Image description

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.
Image description

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.
Image description

The workflow then passed successfully.
Image description

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

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To