gitea icon indicating copy to clipboard operation
gitea copied to clipboard

[Bug] Gitea Actions - Job if statements are ignored

Open TomCoursow opened this issue 2 years ago • 12 comments

Description

General

Hi,

I found that the jobs.<jobid>.if property does not work with Gitea Actions. (Side Note: The steps if does work)

I had a look inside the docs and there I only found that jobs.<jobid>.continue-on-error is not supported but I did not found something for the if property.

Is this feature supported (So a bug) or is this ignored as well (then maybe this can be added in the docs)?

Reproduction

System

  • Host Machine
    • Debian GNU/Linux 10 (buster)
    • Docker Swarm (Server Version: 23.0.1)
    • Gitea and Act Runner Hosted as Docker Swarm Stack
  • Gitea 1.20.0+rc0 ( Docker Image: gitea/gitea:latest )
  • Act Runner v0.2.3 ( Docker Image: gitea/act_runner:latest )

Workflow

File: .gitea/workflows/bug.yml

name: Reproduction of "jobs.<jobid>.if" bug
on: push

jobs:
    failing:
        runs-on: ubuntu-latest
        steps:
            - name: Let the job fail
              run: exit 1

    report:
        runs-on: ubuntu-latest
        needs: failing
        if: ${{ failure() }}
        steps:
            - name: Execute
              run: echo This should run...

Gitea Version

1.20.0+rc0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

gitea_actions_bug_1

gitea_actions_bug_2

Git Version

No response

Operating System

Debian GNU/Linux 10 (buster) - Docker Image: gitea/gitea:latest & gitea/act_runner:latest

How are you running Gitea?

  • Host Machine
    • Debian GNU/Linux 10 (buster)
    • Docker Swarm (Server Version: 23.0.1)

Docker Stack Compose File:

version: "3"

networks:
  gitea:

volumes:
  data:
  runner_data:

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__security__SECRET_KEY=<SECRET>
      - GITEA__security__INTERNAL_TOKEN=<TOKEN>
      - GITEA__service__DISABLE_REGISTRATION=true
      - GITEA__server__LFS_START_SERVER=true
      - GITEA__server__START_SSH_SERVER=true
      - GITEA__server__SSH_PORT=222
      - GITEA__server__SSH_LISTEN_PORT=222
      - GITEA__server__SSH_DOMAIN=<DOMAIN>
      - GITEA__actions__ENABLED=true
    restart: always
    networks:
      - gitea
    volumes:
      - data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "8081:3000"
      - "222:222"

  runner:
    image: gitea/act_runner:latest
    environment:
      CONFIG_FILE: /config.yaml
      GITEA_INSTANCE_URL: https://<DOMAIN>
      GITEA_RUNNER_REGISTRATION_TOKEN: <REG_TOKEN>
      GITEA_RUNNER_NAME: "Gitea Runner"
    volumes:
      - runner_data:/data
      - /docker/configs/gitea_runner/config.yaml:/config.yaml
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "8088:8088"

I applied a config file to the Act Runner to fix the actions/cache Action like mentioned in the Gitea Docs. It only includes the cache properties.

Database

SQLite

TomCoursow avatar Jul 15 '23 10:07 TomCoursow

I'm also having this issue. My guess is that the needs have a higher priority than if or that the gitea actions terminate when the workflow encounters an error in the execution of the workflow.When all I know is that job.if is working properly.

zoy0 avatar Jul 19 '23 16:07 zoy0

I'm running into this as well

pryorda avatar Mar 05 '24 16:03 pryorda

Related to #27906 which has been solved in #29464 but if I read it correctly, it checks for literally always() as a string instead of evaluating it. If you have for example always() && true it doesn't work. Shoud I open another issue?

JohnKiller avatar Mar 14 '24 11:03 JohnKiller

https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions

lunny avatar Mar 14 '24 13:03 lunny

https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions

Can you elaborate? I've read it but I don't get what you mean. Thanks

JohnKiller avatar Mar 18 '24 19:03 JohnKiller

https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions

Can you elaborate? I've read it but I don't get what you mean. Thanks

As a reference Gitea can follow.

lunny avatar Mar 19 '24 05:03 lunny

Related to #27906 which has been solved in #29464 but if I read it correctly, it checks for literally always() as a string instead of evaluating it. If you have for example always() && true it doesn't work. Shoud I open another issue?

Indeed. #29464 can only handle a single always() function. always() always returns true so it's not necessary to use it with other conditions. However, for other status check functions, we need a better solution.

Zettat123 avatar Mar 22 '24 07:03 Zettat123

Maybe we can use https://github.com/expr-lang/expr to evaluate the express.

lunny avatar Mar 22 '24 07:03 lunny

Up

racerxdl avatar Apr 18 '24 09:04 racerxdl

always() has the drawback that as documented it runs even if a job is manually cancelled, which is why the documented workaround is to use if: ${{ !cancelled() }}, but that is not covered by #29464 (nor are other expressions in if:)

bilderbuchi avatar May 17 '24 09:05 bilderbuchi

@lunny could the lack of support for if: beyond a literal always() please be documented in https://docs.gitea.com/usage/actions/comparison#missing-features or https://docs.gitea.com/usage/actions/comparison#unsupported-workflows-syntax? Currently, that page does not mention this lack at all.

bilderbuchi avatar May 17 '24 09:05 bilderbuchi

Reopen as this bug has not been fixed yet

Zettat123 avatar May 23 '24 06:05 Zettat123