Gihub Actions course - lab 2 problem

for this code:

name: Installing Python

on: [push]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-14, windows-latest]
        py-version: ["3.10", "3.11", "3.12"]
    runs-on: ${{matrix.os}}
    steps:
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{matrix.py-version}}

i get:
image

for this code:

name: Installing Python

on: [push]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-14, windows-latest]
        py-version: ['3.10', '3.11', '3.12']
    runs-on: '${{ matrix.os }}'
    steps:
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '${{ matrix.py-version }}'

i get this: screenshot

for this code:

name: Installing Python

on: [push]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-14, windows-latest]
        py-version: ['3.10', '3.11', '3.12']
    runs-on: '${{ matrix.os }}'
    steps:
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '${{ matrix.py-version }}'

gives the previous(2nd) result

but, the solution gives correct results for all

name: Installing Python
'on':
  - push
jobs:
  build:
    runs-on: '${{ matrix.os }}'
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-14
          - windows-latest
        py-version:
          - "3.10"
          - "3.11"
          - "3.12"
    steps:
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '${{ matrix.py-version }}'

note: every code shown here gives completed job status in the github action page.

my question is, why the lab console can’t detect other types of correct(?) code as a solution? or are there some problem in those code?

Hi @ardhendu

The first thing I notice is that you have wrapped the runs-on and with.python-versionusing single quotes. This might cause issues as GitHub Actions won’t interpolate ${{ matrix.os }} or ${{ matrix.py-version }} as variables when enclosed in single quotes.

I would suggest, try using unquoted expressions:

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-14, windows-latest]
        py-version: ['3.10', '3.11', '3.12']
    runs-on: ${{ matrix.os }}
    steps:
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.py-version }}

First of all, in the solution (provided by kodekloud) of that lab, there is single quotes around ${{ matrix.os }} and the other one. (I had provided the solution in the last code section of my answer, which gets accepted for all the lab tasks)

and, I literally copy-pasted your code in the jobs section, but still got one error
image

the code:

name: Installing Python

on: [push]

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-14, windows-latest]
        py-version: ['3.10', '3.11', '3.12']
    runs-on: ${{ matrix.os }}
    steps:
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.py-version }}

so the problem is with Is the build job configured with the correct os matrix? task. and since I’m getting successful workflow completion each time, I’m guessing the problem is with how kodekloud matches the output with the solution result. Can you please check it out?

Hi @ardhendu

I verified with the lab. Thanks for highlighting this.

The issue seems to be how the grader looks for workflow syntax: It accepts a specific syntax as correct and fails others. Even if the Action results in a pass, the grader in the lab fails the test.

I’ll notify the lab team to look at this.

Regards.

thank you for your assistance!
please let me know if the lab team gives any feedback, so that I can mark this topic as solved :white_check_mark:

1 Like