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 template #8786

Open
alexec opened this issue May 17, 2022 · 4 comments
Open

Job template #8786

alexec opened this issue May 17, 2022 · 4 comments
Labels
area/spec Changes to the workflow specification. size/XL 8-16 days type/feature Feature request

Comments

@alexec
Copy link
Contributor

alexec commented May 17, 2022

Summary

Workflows is used by some as a CI solution. Yet it is really needs a new template type to be comparable to GitHub Actions.

The template type could be called “job”. A job runs a series of steps. Each step runs a command (including a shell script) and the job fails if the command fails. Steps execute in sequence. The job fails if any step fails. Steps execute conditionally, usually only if the job is passing.

How’s this different to a steps template? Each step of a job runs in the same container. This makes storing and restoring build and caches faster and simpler.

It also allows users to visualise steps within a container.

Code changes will be similar to adding the container-set template.

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: ci-v2
  annotations:
    workflows.argoproj.io/description: |
      This workflows builds and tests Argo Workflows. 
      
      It demostrates:
      
      * Cache restore and store.
      * Publishing test reports.
spec:
  arguments:
    parameters:
      - name: branch
        value: master

  entrypoint: main

  templates:
    - name: main
      inputs:
        artifacts:
          - name: GOMODCACHE
            path: /go/pkg/mod
            optional: true
            s3:
              key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOMODCACHE"
          - name: GOCACHE
            path: /root/.cache/go-build
            optional: true
            s3:
              key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOCACHE"
      job:
        image: golang:1.18
        workingDir: /go/src/github.com/golang/example
        steps:
          - run: git clone -v -b "{{workflow.parameters.branch}}" --single-branch --depth 1 https://github.com/golang/example.git .
          - run: go mod download -x
          - run: go build ./...
          - run: |
              go install github.com/jstemmer/go-junit-report@latest
              go install github.com/alexec/junit2html@latest
              
              trap 'cat test.out | go-junit-report | junit2html > test-report.html' EXIT
              
              go test -v ./... 2>&1 > test.out
      outputs:
        artifacts:
          - name: test-report
            path: /go/src/github.com/golang/example/test-report.html
            archive:
              none: { }
            s3:
              key: "{{workflow.parameters.branch}}/test-report.html"
          - name: GOMODCACHE
            path: /go/pkg/mod
            optional: true
            s3:
              key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOMODCACHE"
          - name: GOCACHE
            path: /root/.cache/go-build
            optional: true
            s3:
              key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOCACHE"

Use Cases

When would you use this?


Message from the maintainers:

Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.

@alexec alexec added type/feature Feature request area/spec Changes to the workflow specification. labels May 17, 2022
alexec added a commit to alexec/argo-workflows that referenced this issue May 19, 2022
Signed-off-by: Alex Collins <alex_collins@intuit.com>
alexec added a commit to alexec/argo-workflows that referenced this issue May 19, 2022
Signed-off-by: Alex Collins <alex_collins@intuit.com>
alexec added a commit to alexec/argo-workflows that referenced this issue May 19, 2022
Signed-off-by: Alex Collins <alex_collins@intuit.com>
@alexec alexec added the size/XL 8-16 days label Jun 3, 2022
@or-shachar
Copy link
Contributor

@alexec I like the direction!

I think we need to also enhance the cache restore/save to be according to files:

      job:
        image: golang:1.18
        workingDir: /go/src/github.com/golang/example
        steps:
          - run: git clone -v -b "{{workflow.parameters.branch}}" --single-branch --depth 1 https://github.com/golang/example.git .
          - get_artifact:
              name: GOMODCACHE
              path: /go/pkg/mod
              optional: true
              s3:
                key: "github.com/golang/examples/{{ hash 'go.mod' }}/GOMODCACHE"
          - run: go mod download -x
          - save_artifact:
              name: GOMODCACHE
              path: /go/pkg/mod
              optional: true
              s3:
                key: "github.com/golang/examples/{{ hash 'go.mod' }}/GOMODCACHE"
          - run: go build ./...
          - run: |
              go install github.com/jstemmer/go-junit-report@latest
              go install github.com/alexec/junit2html@latest
              
              trap 'cat test.out | go-junit-report | junit2html > test-report.html' EXIT
              
              go test -v ./... 2>&1 > test.out

@alexec
Copy link
Contributor Author

alexec commented Feb 13, 2023

I've spend a few hours today advancing my PoC. It is ready for alpha testing.

  • Read the proposal so you get an understanding of it.
  • Update your the image tags in your deployment (workflow-controller, argo-server) to use :dev-jobs rather than :latest. E.g. quay.io/argoproj/workflow-controller:dev-jobs.
  • Update your workflow-controller deployment to add --executor-image=quay.io/argoproj/argoexec:dev-jobs
  • Create a new job template kubectl apply - f https://github.com/argoproj/argo-workflows/blob/dev-jobs/examples/job-workflowtemplate.yaml.
  • Run the the template from the user interface (I don't have a CLI for you yet).

Testing out the feature will demonstrate that users are interested in it.

@alexec
Copy link
Contributor Author

alexec commented Feb 18, 2023

I forgot, here is a screenshot in action:

image

@tooptoop4
Copy link
Contributor

i tink can close as can achieve this already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spec Changes to the workflow specification. size/XL 8-16 days type/feature Feature request
Projects
None yet
3 participants