Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

job use "strategy:matrix" with gitea actions ,a dynamic array does not work #25179

Open
tomomuy opened this issue Jun 9, 2023 · 5 comments
Open
Labels
topic/gitea-actions related to the actions of Gitea type/bug

Comments

@tomomuy
Copy link

tomomuy commented Jun 9, 2023

Description

In gitea actions, I used dorny/paths-filter as the method of file filtering and took the output as the strategy:matrix parameter for the next job, but instead of generating multiple jobs, gitea actions has and will only generate one job.
This is my test on GitHub Actions and I didn't get this error,[t · tomomuy/monorepo-test@869b14d (github.com)](https://github.com/tomomuy/monorepo-test/actions/runs/5223469755)

Gitea Version

1.20rc0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

gitea actions
image
github actions
image

Git Version

No response

Operating System

Linux

How are you running Gitea?

docker: gitea/gitea:1.20.0-rc0

Database

SQLite

@wolfogre wolfogre added the topic/gitea-actions related to the actions of Gitea label Jun 12, 2023
@wolfogre
Copy link
Member

The workflow file
name: Build Service
on: 
  push: 
    branches: [main]
jobs:
  pre-build:
    runs-on: ubuntu-latest
    outputs:
      service: ${{ steps.filter.outputs.changes }}

    steps:

    - name: Checkout
      uses: actions/checkout@v3


    - uses: dorny/paths-filter@v2
      id: filter
      with:
        base: ${{ github.ref }}
        filters: |
          wall:
            - wall/**
          user:
            - user/**
            - basic/**'
            - pom.xml
          gateway:
            - gateway/**
            - basic/**'
            - pom.xml                  


  build:

    needs: pre-build
    strategy:
      matrix:
        service: ${{ fromJSON(needs.pre-build.outputs.service) }}
    runs-on: ubuntu-latest

    steps:

    - name: echo
      run: |
        echo "构建${{ matrix.service }}"
        echo "${{ needs.pre-build.outputs.service }}"
        echo "${{ fromJSON(needs.pre-build.outputs.service) }}"        

    

The point is

    strategy:
      matrix:
        service: ${{ fromJSON(needs.pre-build.outputs.service) }}

Although Gitea can get the outputs after #24230, it doesn't evaluate expressions for matrix, only for runs-on. It could be fixed at jobparser.go#L45-L61.

And maybe it could also be fixed when #24603 is done.

@tomomuy
Copy link
Author

tomomuy commented Jun 12, 2023

I am very much looking forward to the completion of this operation

@tomomuy tomomuy closed this as completed Jun 12, 2023
@wolfogre wolfogre reopened this Jun 13, 2023
@gilesbradshaw
Copy link

I think I have this issue too:

name: schema-test
run-name: test setting matix from JSON
on:
  push:
jobs:
  job1:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
    - id: set-matrix
      run: echo "matrix=[\"afile\", \"another file\"]" >> $GITHUB_OUTPUT
  job2:
    needs: job1
    runs-on: ubuntu-latest
    strategy:
      matrix:
        manifest: ${{ fromJSON(needs.job1.outputs.matrix) }}
    steps:
    - run: echo ${{ matrix.manifest }}


maybe related to nektos/act#927

@davidfrickert
Copy link

davidfrickert commented Apr 1, 2024

Having the same issue, matrix seems to be empty when trying to pass data from a previous job into it.
Also seems like matrix variables cannot be used on Job or Step names. I would expect that one new Job/Step would be created per detected matrix combo?
Would love to see this work as right now it kinda limits the flexibility of Gitea Actions.

@davidfrickert
Copy link

davidfrickert commented Apr 1, 2024

I think that there are at least 2 issues:

  • matrix templates are not evaluated
  • template evaluation at matrix/run-on is not able to use job outputs

did a simple test by trying to use an output of a previous job in runs-on which does evaluate the template but did not work
it seems the whole workflow is processed at once in the beginning and all jobs are generated at that time, so it is not possible to use data from previous jobs to define metadata of next jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

No branches or pull requests

4 participants