Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ spec:
Considering [GitHub Workflows](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses)
has a complex syntax. Currently, we support the following ones:

* [Event filter](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on)
* Support `on.push` and `on.merge_request`
* keyword `uses`
* support `actions/checkout`, `actions/setup-go`, `goreleaser/goreleaser-action` and `docker://`
* keyword `run`
* keyword `env`
* [concurrency](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency)
* Not support `cancel-in-progress` yet

There are some limitations. For example, only the first job could be recognized in each file.
1 change: 0 additions & 1 deletion cmd/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ spec:
resources:
requests:
storage: 64Mi
templates:
- name: main
dag:
Expand Down
2 changes: 0 additions & 2 deletions cmd/data/combine-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down Expand Up @@ -58,7 +57,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down
1 change: 0 additions & 1 deletion cmd/data/one-workflow-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down
1 change: 0 additions & 1 deletion cmd/data/one-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down
6 changes: 5 additions & 1 deletion pkg/argo-workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ spec:
resources:
requests:
storage: 64Mi

{{- if .Concurrency}}
synchronization:
mutex:
name: {{.Concurrency}}
{{- end}}
templates:
- name: main
dag:
Expand Down
4 changes: 4 additions & 0 deletions pkg/argo-workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func TestWorkflow_ConvertToArgoWorkflow(t *testing.T) {
name: "complex event",
githubActions: "data/github-action-complex-event.yaml",
argoWorkflows: "data/argo-workflows-complex-event.yaml",
}, {
name: "with concurrency",
githubActions: "data/github-actions-concurrency.yaml",
argoWorkflows: "data/argo-workflows-concurrency.yaml",
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/data/argo-workflows-complex-event.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down
76 changes: 76 additions & 0 deletions pkg/data/argo-workflows-concurrency.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: build
spec:
entrypoint: main
arguments:
parameters:
- name: branch
default: master
- name: pr
default: -1
volumeClaimTemplates:
- metadata:
name: work
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 64Mi
synchronization:
mutex:
name: test
templates:
- name: main
dag:
tasks:
- name: clone
template: clone
- name: test
template: test
depends: clone
- name: goreleaser
template: goreleaser
depends: test
- name: clone
script:
image: alpine/git:v2.26.2
command: [sh]
source: |
branch=$(echo {{workflow.parameters.branch}} | sed -e 's/refs\/heads\///g')
git clone --branch $branch https://gitee.com/LinuxSuRen/yaml-readme .
if [ {{workflow.parameters.pr}} != -1 ]; then
git fetch origin merge-requests/{{workflow.parameters.pr}}/head:mr-{{workflow.parameters.pr}}
git checkout mr-{{workflow.parameters.pr}}
fi
volumeMounts:
- mountPath: /work
name: work
workingDir: /work
- name: test
script:
image: golang:1.18
command: [sh]
env:
- name: GOPROXY
value: https://goproxy.io,direct
source: |
go test ./... -coverprofile coverage.out
volumeMounts:
- mountPath: /work
name: work
workingDir: /work
- name: goreleaser
script:
image: goreleaser/goreleaser:v1.13.1
command: [sh]
env:
- name: GOPROXY
value: https://goproxy.io,direct
source: |
goreleaser release --skip-publish --rm-dist
volumeMounts:
- mountPath: /work
name: work
workingDir: /work
1 change: 0 additions & 1 deletion pkg/data/argo-workflows-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down
1 change: 0 additions & 1 deletion pkg/data/argo-workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ spec:
resources:
requests:
storage: 64Mi

templates:
- name: main
dag:
Expand Down
26 changes: 26 additions & 0 deletions pkg/data/github-actions-concurrency.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build
concurrency: test
jobs:
build:
name: build
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v3
with:
go-version: 1.18
id: go
- name: clone
uses: actions/[email protected]
- name: test
env:
GOPROXY: https://goproxy.io,direct
run: |
go test ./... -coverprofile coverage.out
- name: GoReleaser
uses: goreleaser/[email protected]
env:
GOPROXY: https://goproxy.io,direct
with:
version: latest
args: release --skip-publish --rm-dist
7 changes: 4 additions & 3 deletions pkg/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
)

type Workflow struct {
Name string
On interface{} // could be: string, []string, Event
Jobs map[string]Job
Name string
On interface{} // could be: string, []string, Event
Jobs map[string]Job
Concurrency string

// extra fields
GitRepository string
Expand Down