Inline the format pipeline.
Some checks failed
rust-foreign-document-test Build rust-foreign-document-test has failed
rust-test Build rust-test has failed
rust-build Build rust-build has failed
format Build format has succeeded
clippy Build clippy has failed

This commit is contained in:
Tom Alexander 2024-04-06 11:54:06 -04:00
parent 4dee130873
commit 4e9f1e4fac
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
6 changed files with 156 additions and 170 deletions

View File

@ -1,9 +1,13 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: rustfmt
name: rust-format
spec:
pipelineSpec:
timeouts:
pipeline: "2h0m0s"
tasks: "1h0m40s"
finally: "0h30m0s"
params:
- name: image-name
description: The name for the built image
@ -14,35 +18,17 @@ spec:
- name: path-to-dockerfile
description: The path to the Dockerfile
type: string
- name: GIT_USER_NAME
description: The username for git
type: string
default: "fluxcdbot"
- name: GIT_USER_EMAIL
description: The email for git
type: string
default: "fluxcdbot@users.noreply.github.com"
tasks:
- name: do-stuff
taskSpec:
metadata: {}
stepTemplate:
image: alpine:3.18
name: ""
resources:
requests:
cpu: 10m
memory: 600Mi
workingDir: /workspace/source
steps:
- image: alpine:3.18
name: do-stuff-step
script: |
#!/usr/bin/env sh
echo "hello world"
- name: report-pending
taskRef:
name: gitea-set-status
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/gitea-set-status/0.1/gitea-set-status.yaml
runAfter:
- fetch-repository
params:
@ -62,7 +48,14 @@ spec:
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
- name: fetch-repository
taskRef:
name: git-clone
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/git-clone/0.9/git-clone.yaml
workspaces:
- name: output
workspace: git-source
@ -75,7 +68,14 @@ spec:
value: "true"
- name: build-image
taskRef:
name: kaniko
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/kaniko/0.6//kaniko.yaml
params:
- name: IMAGE
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
@ -102,42 +102,62 @@ spec:
workspace: docker-credentials
runAfter:
- fetch-repository
- name: rustfmt
taskRef:
name: run-docker-image
workspaces:
- name: source
workspace: git-source
runAfter:
- build-image
- name: run-cargo-fmt
taskSpec:
metadata: {}
params:
- name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
- name: cargo-fix
taskRef:
name: run-docker-image
type: string
description: Docker image to run.
default: alpine:3.18
stepTemplate:
image: alpine:3.18
name: ""
resources:
requests:
cpu: 10m
memory: 600Mi
workingDir: /workspace/source
workspaces:
- name: source
mountPath: /source
- name: cargo-cache
mountPath: /usr/local/cargo/registry
optional: true
steps:
- name: run
image: $(params.docker-image)
workingDir: "$(workspaces.source.path)"
command: ["cargo", "fmt"]
args: []
env:
- name: CARGO_TARGET_DIR
value: /target
workspaces:
- name: source
workspace: git-source
- name: cargo-cache
workspace: cargo-cache
runAfter:
- rustfmt
- build-image
params:
- name: command
value: ["cargo", "fix"]
- name: args
value: ["--all-targets", "--all-features", "--allow-dirty"]
- name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
- name: commit-changes
taskRef:
name: git-cli
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/git-cli/0.4/git-cli.yaml
params:
- name: GIT_USER_NAME
value: $(params.GIT_USER_NAME)
value: fluxcdbot
- name: GIT_USER_EMAIL
value: $(params.GIT_USER_EMAIL)
value: "fluxcdbot@users.noreply.github.com"
- name: GIT_SCRIPT
value: |
pwd
@ -153,7 +173,7 @@ spec:
- name: source
workspace: git-source
runAfter:
- cargo-fix
- run-cargo-fmt
finally:
- name: report-success
when:
@ -161,7 +181,14 @@ spec:
operator: in
values: ["Succeeded", "Completed"]
taskRef:
name: gitea-set-status
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/gitea-set-status/0.1/gitea-set-status.yaml
params:
- name: CONTEXT
value: "$(params.JOB_NAME)"
@ -183,7 +210,14 @@ spec:
operator: in
values: ["Failed"]
taskRef:
name: gitea-set-status
resolver: git
params:
- name: url
value: https://github.com/tektoncd/catalog.git
- name: revision
value: df36b3853a5657fd883015cdbf07ad6466918acf
- name: pathInRepo
value: task/gitea-set-status/0.1/gitea-set-status.yaml
params:
- name: CONTEXT
value: "$(params.JOB_NAME)"
@ -199,9 +233,46 @@ spec:
value: failure
- name: TARGET_URL
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
- name: cargo-cache-autoclean
taskSpec:
metadata: {}
params:
- name: docker-image
type: string
description: Docker image to run.
default: alpine:3.18
stepTemplate:
image: alpine:3.18
name: ""
resources:
requests:
cpu: 10m
memory: 600Mi
workingDir: /workspace/source
workspaces:
- name: source
mountPath: /source
- name: cargo-cache
mountPath: /usr/local/cargo/registry
optional: true
steps:
- name: run
image: $(params.docker-image)
workingDir: "$(workspaces.source.path)"
command: [cargo, cache, --autoclean]
args: []
workspaces:
- name: source
workspace: git-source
- name: cargo-cache
workspace: cargo-cache
params:
- name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
workspaces:
- name: git-source
- name: docker-credentials
- name: cargo-cache
workspaces:
- name: git-source
volumeClaimTemplate:
@ -220,11 +291,10 @@ spec:
secret:
secretName: harbor-plain
serviceAccountName: build-bot
timeout: 240h0m0s
params:
- name: image-name
value: "harbor.fizz.buzz/private/organic-fmt"
value: "harbor.fizz.buzz/private/organic-development"
- name: path-to-image-context
value: docker/cargo_fmt/
value: docker/organic_development/
- name: path-to-dockerfile
value: docker/cargo_fmt/Dockerfile
value: docker/organic_development/Dockerfile

View File

@ -2,34 +2,27 @@ apiVersion: config.lighthouse.jenkins-x.io/v1alpha1
kind: TriggerConfig
spec:
postsubmits:
# - name: rustfmt
# source: "pipeline-rustfmt.yaml"
# # Override https-based url from lighthouse events.
# clone_uri: "git@code.fizz.buzz:talexander/organic.git"
# branches:
# - ^main$
# - ^master$
# - name: rust-test
# source: "pipeline-rust-test.yaml"
# # Override https-based url from lighthouse events.
# clone_uri: "git@code.fizz.buzz:talexander/organic.git"
# skip_branches:
# # We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
# - "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
# - name: rust-foreign-document-test
# source: "pipeline-foreign-document-test.yaml"
# # Override https-based url from lighthouse events.
# clone_uri: "git@code.fizz.buzz:talexander/organic.git"
# skip_branches:
# # We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
# - "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
# - name: rust-build
# source: "pipeline-rust-build.yaml"
# # Override https-based url from lighthouse events.
# clone_uri: "git@code.fizz.buzz:talexander/organic.git"
# skip_branches:
# # We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
# - "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
- name: rust-test
source: "pipeline-rust-test.yaml"
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/organic.git"
skip_branches:
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
- name: rust-foreign-document-test
source: "pipeline-foreign-document-test.yaml"
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/organic.git"
skip_branches:
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
- name: rust-build
source: "pipeline-rust-build.yaml"
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/organic.git"
skip_branches:
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
- name: clippy
source: "pipeline-rust-clippy.yaml"
# Override https-based url from lighthouse events.
@ -37,3 +30,10 @@ spec:
skip_branches:
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
- name: format
source: "pipeline-format.yaml"
# Override https-based url from lighthouse events.
clone_uri: "git@code.fizz.buzz:talexander/organic.git"
skip_branches:
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"

View File

@ -1,6 +0,0 @@
FROM rustlang/rust:nightly-alpine3.19
RUN apk add --no-cache musl-dev
RUN rustup component add rustfmt
ENTRYPOINT ["cargo", "fmt"]

View File

@ -1,36 +0,0 @@
IMAGE_NAME:=cargo-fmt
# REMOTE_REPO:=harbor.fizz.buzz/private
.PHONY: all
all: build push
.PHONY: build
build:
docker build -t $(IMAGE_NAME) -f Dockerfile .
.PHONY: push
push:
ifdef REMOTE_REPO
docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
docker push $(REMOTE_REPO)/$(IMAGE_NAME)
else
@echo "REMOTE_REPO not defined, not pushing to a remote repo."
endif
.PHONY: clean
clean:
docker rmi $(IMAGE_NAME)
ifdef REMOTE_REPO
docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
else
@echo "REMOTE_REPO not defined, not removing from remote repo."
endif
# NOTE: This target will write to folders underneath the git-root
.PHONY: run
run: build
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source $(IMAGE_NAME)
.PHONY: shell
shell: build
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source $(IMAGE_NAME)

View File

@ -1,5 +0,0 @@
FROM rustlang/rust:nightly-alpine3.19
RUN apk add --no-cache musl-dev
ENTRYPOINT ["cargo", "clippy", "--no-deps", "--all-targets", "--all-features", "--", "-D", "warnings"]

View File

@ -1,37 +0,0 @@
IMAGE_NAME:=organic-clippy
# REMOTE_REPO:=harbor.fizz.buzz/private
.PHONY: all
all: build push
.PHONY: build
build:
docker build -t $(IMAGE_NAME) -f Dockerfile .
.PHONY: push
push:
ifdef REMOTE_REPO
docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
docker push $(REMOTE_REPO)/$(IMAGE_NAME)
else
@echo "REMOTE_REPO not defined, not pushing to a remote repo."
endif
.PHONY: clean
clean:
docker rmi $(IMAGE_NAME)
ifdef REMOTE_REPO
docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
else
@echo "REMOTE_REPO not defined, not removing from remote repo."
endif
docker volume rm rust-cache cargo-cache
# NOTE: This target will write to folders underneath the git-root
.PHONY: run
run: build
docker run --rm --init -t --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
.PHONY: shell
shell: build
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)