Compare commits
134 Commits
f4eff5ca56
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
482d5ecfa3 | ||
|
|
84b8ddb582 | ||
|
|
113bb5888a | ||
|
|
bf5fe6920b | ||
|
|
4b52ed0d2a | ||
|
|
d2c558ccfa | ||
|
|
a01f78b510 | ||
|
|
d80b473fae | ||
|
|
e6b4bc3d94 | ||
|
|
c6cde8db74 | ||
|
|
841a348dd0 | ||
|
|
b46fae331b | ||
|
|
7223e08df3 | ||
|
|
8321f83dac | ||
|
|
bd441a0293 | ||
|
|
f5a07e0d70 | ||
|
|
9d750ed5e1 | ||
|
|
9f111fe445 | ||
|
|
a4e433dab1 | ||
|
|
4e9f1e4fac | ||
|
|
4dee130873 | ||
|
|
8e712532e1 | ||
|
|
4b85236c5f | ||
|
|
66f003e6fd | ||
|
|
b35a2d5f5a | ||
|
|
320b5f8568 | ||
|
|
99b2af6c99 | ||
|
|
6e71acdb7d | ||
|
|
8406d37991 | ||
|
|
64bb597908 | ||
|
|
068864ea87 | ||
|
|
03a3ddbd63 | ||
|
|
122adee23b | ||
|
|
556afecbb8 | ||
|
|
e4407cbdd1 | ||
|
|
f57d60dab0 | ||
|
|
0aa3939a75 | ||
|
|
52cb81e75e | ||
|
|
945121202d | ||
|
|
f4e0dddd9d | ||
|
|
6b62176fd0 | ||
|
|
44483b4d54 | ||
|
|
48d3de77fe | ||
|
|
680b176501 | ||
|
|
dc0338e978 | ||
|
|
ff3e0a50af | ||
|
|
03c8c07fe0 | ||
|
|
3a6fc5b669 | ||
|
|
d258cdb839 | ||
|
|
aa5629354e | ||
|
|
efc4a04829 | ||
|
|
dd611ea64a | ||
|
|
4bd5f3bec7 | ||
|
|
c2b3509b6a | ||
|
|
7f3f5fb889 | ||
|
|
e0fbf17226 | ||
|
|
4e18cbafba | ||
|
|
46c36d7f3e | ||
|
|
c46a935cfc | ||
|
|
f50415cb32 | ||
|
|
4f1a151e97 | ||
|
|
c8e3fdba51 | ||
|
|
4b3fc20c62 | ||
|
|
3131f8ac64 | ||
|
|
60a4835590 | ||
|
|
172d72aa46 | ||
|
|
b4fcc6500b | ||
|
|
ddb6f31562 | ||
|
|
dc080b30fc | ||
|
|
9901e17437 | ||
|
|
ea000894f0 | ||
|
|
e7742b529a | ||
|
|
8eba0c4923 | ||
|
|
e0c0070a13 | ||
|
|
65ce116998 | ||
|
|
e348e7d4e3 | ||
|
|
492090470c | ||
|
|
3ec900c8df | ||
|
|
d0a008ed22 | ||
|
|
f2292f1c07 | ||
|
|
44392cfcca | ||
|
|
110630d230 | ||
|
|
ebe12d96c1 | ||
|
|
24c8ac8e21 | ||
|
|
259ad6e242 | ||
|
|
dd1f7c7777 | ||
|
|
c1b471208d | ||
|
|
606bab9e6d | ||
|
|
0edf5620a2 | ||
|
|
cdf87641c5 | ||
|
|
eb2995dd3b | ||
|
|
cd6a64c015 | ||
|
|
a4a83d047d | ||
|
|
a4414369ce | ||
|
|
83e4b72307 | ||
|
|
34b3e4fa7b | ||
|
|
c0e879dc1e | ||
|
|
fa31b001f4 | ||
|
|
0897061ff6 | ||
|
|
28a3e1bc7b | ||
|
|
3fd3d20722 | ||
|
|
90735586b5 | ||
|
|
78befc7665 | ||
|
|
ef549d3b19 | ||
|
|
777c756a7f | ||
|
|
037caf369c | ||
|
|
54085b5833 | ||
|
|
2bfa8e59e7 | ||
|
|
5d31db39a4 | ||
|
|
adcd0de7e4 | ||
|
|
c2f9789a64 | ||
|
|
579cbb5d11 | ||
|
|
cad2be43bf | ||
|
|
a0a4f0eb90 | ||
|
|
9f4f8e79ce | ||
|
|
77e0dbb42e | ||
|
|
eff5cdbf40 | ||
|
|
eef3571299 | ||
|
|
f227d8405e | ||
|
|
9520e5814b | ||
|
|
28ad4fd046 | ||
|
|
7626a69fa1 | ||
|
|
121c0ce516 | ||
|
|
5a64db98fe | ||
|
|
abfae9c6c0 | ||
|
|
5272e2f1b4 | ||
|
|
90d4b11922 | ||
|
|
d552ef6569 | ||
|
|
f050e9b6a8 | ||
|
|
a5e108bc37 | ||
|
|
58290515b5 | ||
|
|
423f65046e | ||
|
|
badeaf8246 | ||
|
|
d38100581c |
@@ -2,3 +2,4 @@
|
|||||||
target
|
target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
notes/
|
notes/
|
||||||
|
.lighthouse/
|
||||||
|
|||||||
@@ -1,191 +0,0 @@
|
|||||||
apiVersion: tekton.dev/v1beta1
|
|
||||||
kind: PipelineRun
|
|
||||||
metadata:
|
|
||||||
name: clippy
|
|
||||||
spec:
|
|
||||||
pipelineSpec:
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
description: The name for the built image
|
|
||||||
type: string
|
|
||||||
- name: path-to-image-context
|
|
||||||
description: The path to the build context
|
|
||||||
type: string
|
|
||||||
- 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
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has started"
|
|
||||||
- name: STATE
|
|
||||||
value: pending
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: fetch-repository
|
|
||||||
taskRef:
|
|
||||||
name: git-clone
|
|
||||||
workspaces:
|
|
||||||
- name: output
|
|
||||||
workspace: git-source
|
|
||||||
params:
|
|
||||||
- name: url
|
|
||||||
value: $(params.REPO_URL)
|
|
||||||
- name: revision
|
|
||||||
value: $(params.PULL_BASE_SHA)
|
|
||||||
- name: deleteExisting
|
|
||||||
value: "true"
|
|
||||||
- name: build-image
|
|
||||||
taskRef:
|
|
||||||
name: kaniko
|
|
||||||
params:
|
|
||||||
- name: IMAGE
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: CONTEXT
|
|
||||||
value: $(params.path-to-image-context)
|
|
||||||
- name: DOCKERFILE
|
|
||||||
value: $(params.path-to-dockerfile)
|
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
|
||||||
value:
|
|
||||||
- --cache=true
|
|
||||||
- --cache-copy-layers
|
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
|
||||||
- --use-new-run # Should result in a speed-up
|
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
|
||||||
- --snapshot-mode=redo
|
|
||||||
- --skip-unused-stages=true
|
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: dockerconfig
|
|
||||||
workspace: docker-credentials
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
- name: clippy
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- build-image
|
|
||||||
params:
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
finally:
|
|
||||||
- name: report-success
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Succeeded", "Completed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has succeeded"
|
|
||||||
- name: STATE
|
|
||||||
value: success
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: report-failure
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Failed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has failed"
|
|
||||||
- name: STATE
|
|
||||||
value: failure
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
workspaces:
|
|
||||||
- name: git-source
|
|
||||||
- name: docker-credentials
|
|
||||||
workspaces:
|
|
||||||
- name: git-source
|
|
||||||
volumeClaimTemplate:
|
|
||||||
spec:
|
|
||||||
storageClassName: "nfs-client"
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 10Gi
|
|
||||||
subPath: rust-source
|
|
||||||
- name: cargo-cache
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: organic-cargo-cache-clippy
|
|
||||||
- name: docker-credentials
|
|
||||||
secret:
|
|
||||||
secretName: harbor-plain
|
|
||||||
serviceAccountName: build-bot
|
|
||||||
timeout: 240h0m0s
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
value: "harbor.fizz.buzz/private/organic-clippy"
|
|
||||||
- name: path-to-image-context
|
|
||||||
value: docker/organic_clippy/
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
value: docker/organic_clippy/Dockerfile
|
|
||||||
@@ -1,203 +0,0 @@
|
|||||||
apiVersion: tekton.dev/v1beta1
|
|
||||||
kind: PipelineRun
|
|
||||||
metadata:
|
|
||||||
name: rust-foreign-document-test
|
|
||||||
spec:
|
|
||||||
pipelineSpec:
|
|
||||||
timeouts:
|
|
||||||
pipeline: "2h0m0s"
|
|
||||||
tasks: "1h0m40s"
|
|
||||||
finally: "0h30m0s"
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
description: The name for the built image
|
|
||||||
type: string
|
|
||||||
- name: path-to-image-context
|
|
||||||
description: The path to the build context
|
|
||||||
type: string
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
description: The path to the Dockerfile
|
|
||||||
type: string
|
|
||||||
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
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has started"
|
|
||||||
- name: STATE
|
|
||||||
value: pending
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: fetch-repository
|
|
||||||
taskRef:
|
|
||||||
name: git-clone
|
|
||||||
workspaces:
|
|
||||||
- name: output
|
|
||||||
workspace: git-source
|
|
||||||
params:
|
|
||||||
- name: url
|
|
||||||
value: $(params.REPO_URL)
|
|
||||||
- name: revision
|
|
||||||
value: $(params.PULL_BASE_SHA)
|
|
||||||
- name: deleteExisting
|
|
||||||
value: "true"
|
|
||||||
- name: build-image
|
|
||||||
taskRef:
|
|
||||||
name: kaniko
|
|
||||||
params:
|
|
||||||
- name: IMAGE
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: CONTEXT
|
|
||||||
value: $(params.path-to-image-context)
|
|
||||||
- name: DOCKERFILE
|
|
||||||
value: $(params.path-to-dockerfile)
|
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
|
||||||
value:
|
|
||||||
- --target=foreign-document-test
|
|
||||||
- --cache=true
|
|
||||||
- --cache-copy-layers
|
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
|
||||||
- --use-new-run # Should result in a speed-up
|
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
|
||||||
- --snapshot-mode=redo
|
|
||||||
- --skip-unused-stages=true
|
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: dockerconfig
|
|
||||||
workspace: docker-credentials
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
- name: run-image
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- build-image
|
|
||||||
params:
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
finally:
|
|
||||||
- name: report-success
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Succeeded", "Completed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has succeeded"
|
|
||||||
- name: STATE
|
|
||||||
value: success
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: report-failure
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Failed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has failed"
|
|
||||||
- name: STATE
|
|
||||||
value: failure
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: cargo-cache-autoclean
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
params:
|
|
||||||
- name: command
|
|
||||||
value: [cargo, cache, --autoclean]
|
|
||||||
- name: args
|
|
||||||
value: []
|
|
||||||
- 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:
|
|
||||||
spec:
|
|
||||||
storageClassName: "nfs-client"
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 10Gi
|
|
||||||
subPath: rust-source
|
|
||||||
- name: cargo-cache
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: organic-cargo-cache-test-foreign-document
|
|
||||||
- name: docker-credentials
|
|
||||||
secret:
|
|
||||||
secretName: harbor-plain
|
|
||||||
serviceAccountName: build-bot
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
value: "harbor.fizz.buzz/private/organic-test-foreign-document"
|
|
||||||
- name: path-to-image-context
|
|
||||||
value: docker/organic_test/
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
value: docker/organic_test/Dockerfile
|
|
||||||
@@ -1,332 +0,0 @@
|
|||||||
apiVersion: tekton.dev/v1beta1
|
|
||||||
kind: PipelineRun
|
|
||||||
metadata:
|
|
||||||
name: rust-build
|
|
||||||
spec:
|
|
||||||
pipelineSpec:
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
description: The name for the built image
|
|
||||||
type: string
|
|
||||||
- name: path-to-image-context
|
|
||||||
description: The path to the build context
|
|
||||||
type: string
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
description: The path to the Dockerfile
|
|
||||||
type: string
|
|
||||||
tasks:
|
|
||||||
- name: report-pending
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has started"
|
|
||||||
- name: STATE
|
|
||||||
value: pending
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: fetch-repository
|
|
||||||
taskRef:
|
|
||||||
name: git-clone
|
|
||||||
workspaces:
|
|
||||||
- name: output
|
|
||||||
workspace: git-source
|
|
||||||
params:
|
|
||||||
- name: url
|
|
||||||
value: $(params.REPO_URL)
|
|
||||||
- name: revision
|
|
||||||
value: $(params.PULL_BASE_SHA)
|
|
||||||
- name: deleteExisting
|
|
||||||
value: "true"
|
|
||||||
- name: build-image
|
|
||||||
taskRef:
|
|
||||||
name: kaniko
|
|
||||||
params:
|
|
||||||
- name: IMAGE
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: CONTEXT
|
|
||||||
value: $(params.path-to-image-context)
|
|
||||||
- name: DOCKERFILE
|
|
||||||
value: $(params.path-to-dockerfile)
|
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
|
||||||
value:
|
|
||||||
- --cache=true
|
|
||||||
- --cache-copy-layers
|
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
|
||||||
- --use-new-run # Should result in a speed-up
|
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
|
||||||
- --snapshot-mode=redo
|
|
||||||
- --skip-unused-stages=true
|
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: dockerconfig
|
|
||||||
workspace: docker-credentials
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
- name: run-image-none
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- build-image
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value: ["--no-default-features"]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-tracing
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-none
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value: ["--no-default-features", "--features", "tracing"]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-compare
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-tracing
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value: ["--no-default-features", "--features", "compare"]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-default
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-compare
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value: []
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-tracing-compare
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-default
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value: ["--no-default-features", "--features", "tracing,compare"]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-compare-foreign
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-tracing-compare
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value:
|
|
||||||
[
|
|
||||||
"--no-default-features",
|
|
||||||
"--features",
|
|
||||||
"compare,foreign_document_test",
|
|
||||||
]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-all
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-compare-foreign
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value:
|
|
||||||
[
|
|
||||||
"--no-default-features",
|
|
||||||
"--features",
|
|
||||||
"tracing,compare,foreign_document_test",
|
|
||||||
]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-wasm
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-all
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value:
|
|
||||||
[
|
|
||||||
"--target",
|
|
||||||
"wasm32-unknown-unknown",
|
|
||||||
"--profile",
|
|
||||||
"wasm",
|
|
||||||
"--bin",
|
|
||||||
"wasm",
|
|
||||||
"--no-default-features",
|
|
||||||
"--features",
|
|
||||||
"wasm",
|
|
||||||
]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: run-image-wasm-test
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- run-image-wasm
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value:
|
|
||||||
[
|
|
||||||
"--bin",
|
|
||||||
"wasm_test",
|
|
||||||
"--no-default-features",
|
|
||||||
"--features",
|
|
||||||
"wasm_test",
|
|
||||||
]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
finally:
|
|
||||||
- name: report-success
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Succeeded", "Completed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has succeeded"
|
|
||||||
- name: STATE
|
|
||||||
value: success
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: report-failure
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Failed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has failed"
|
|
||||||
- name: STATE
|
|
||||||
value: failure
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: cargo-cache-autoclean
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
params:
|
|
||||||
- name: command
|
|
||||||
value: [cargo, cache, --autoclean]
|
|
||||||
- name: args
|
|
||||||
value: []
|
|
||||||
- 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:
|
|
||||||
spec:
|
|
||||||
storageClassName: "nfs-client"
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 10Gi
|
|
||||||
subPath: rust-source
|
|
||||||
- name: cargo-cache
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: organic-cargo-cache-build
|
|
||||||
- name: docker-credentials
|
|
||||||
secret:
|
|
||||||
secretName: harbor-plain
|
|
||||||
serviceAccountName: build-bot
|
|
||||||
timeout: 240h0m0s
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
value: "harbor.fizz.buzz/private/organic-build"
|
|
||||||
- name: path-to-image-context
|
|
||||||
value: docker/organic_build/
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
value: docker/organic_build/Dockerfile
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
apiVersion: tekton.dev/v1beta1
|
|
||||||
kind: PipelineRun
|
|
||||||
metadata:
|
|
||||||
name: rust-test
|
|
||||||
spec:
|
|
||||||
pipelineSpec:
|
|
||||||
timeouts:
|
|
||||||
pipeline: "2h0m0s"
|
|
||||||
tasks: "1h0m40s"
|
|
||||||
finally: "0h30m0s"
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
description: The name for the built image
|
|
||||||
type: string
|
|
||||||
- name: path-to-image-context
|
|
||||||
description: The path to the build context
|
|
||||||
type: string
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
description: The path to the Dockerfile
|
|
||||||
type: string
|
|
||||||
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
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has started"
|
|
||||||
- name: STATE
|
|
||||||
value: pending
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: fetch-repository
|
|
||||||
taskRef:
|
|
||||||
name: git-clone
|
|
||||||
workspaces:
|
|
||||||
- name: output
|
|
||||||
workspace: git-source
|
|
||||||
params:
|
|
||||||
- name: url
|
|
||||||
value: $(params.REPO_URL)
|
|
||||||
- name: revision
|
|
||||||
value: $(params.PULL_BASE_SHA)
|
|
||||||
- name: deleteExisting
|
|
||||||
value: "true"
|
|
||||||
- name: build-image
|
|
||||||
taskRef:
|
|
||||||
name: kaniko
|
|
||||||
params:
|
|
||||||
- name: IMAGE
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: CONTEXT
|
|
||||||
value: $(params.path-to-image-context)
|
|
||||||
- name: DOCKERFILE
|
|
||||||
value: $(params.path-to-dockerfile)
|
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
|
||||||
value:
|
|
||||||
- --target=tester
|
|
||||||
- --cache=true
|
|
||||||
- --cache-copy-layers
|
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
|
||||||
- --use-new-run # Should result in a speed-up
|
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
|
||||||
- --snapshot-mode=redo
|
|
||||||
- --skip-unused-stages=true
|
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: dockerconfig
|
|
||||||
workspace: docker-credentials
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
- name: run-image
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- build-image
|
|
||||||
params:
|
|
||||||
- name: args
|
|
||||||
value:
|
|
||||||
[
|
|
||||||
--no-default-features,
|
|
||||||
--features,
|
|
||||||
compare,
|
|
||||||
--no-fail-fast,
|
|
||||||
--lib,
|
|
||||||
--test,
|
|
||||||
test_loader,
|
|
||||||
]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
finally:
|
|
||||||
- name: report-success
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Succeeded", "Completed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has succeeded"
|
|
||||||
- name: STATE
|
|
||||||
value: success
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: report-failure
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Failed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has failed"
|
|
||||||
- name: STATE
|
|
||||||
value: failure
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: cargo-cache-autoclean
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
params:
|
|
||||||
- name: command
|
|
||||||
value: [cargo, cache, --autoclean]
|
|
||||||
- name: args
|
|
||||||
value: []
|
|
||||||
- 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:
|
|
||||||
spec:
|
|
||||||
storageClassName: "nfs-client"
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 10Gi
|
|
||||||
subPath: rust-source
|
|
||||||
- name: cargo-cache
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: organic-cargo-cache-test
|
|
||||||
- name: docker-credentials
|
|
||||||
secret:
|
|
||||||
secretName: harbor-plain
|
|
||||||
serviceAccountName: build-bot
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
value: "harbor.fizz.buzz/private/organic-test"
|
|
||||||
- name: path-to-image-context
|
|
||||||
value: docker/organic_test/
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
value: docker/organic_test/Dockerfile
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
apiVersion: tekton.dev/v1beta1
|
|
||||||
kind: PipelineRun
|
|
||||||
metadata:
|
|
||||||
name: rustfmt
|
|
||||||
spec:
|
|
||||||
pipelineSpec:
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
description: The name for the built image
|
|
||||||
type: string
|
|
||||||
- name: path-to-image-context
|
|
||||||
description: The path to the build context
|
|
||||||
type: string
|
|
||||||
- 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
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has started"
|
|
||||||
- name: STATE
|
|
||||||
value: pending
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: fetch-repository
|
|
||||||
taskRef:
|
|
||||||
name: git-clone
|
|
||||||
workspaces:
|
|
||||||
- name: output
|
|
||||||
workspace: git-source
|
|
||||||
params:
|
|
||||||
- name: url
|
|
||||||
value: $(params.REPO_URL)
|
|
||||||
- name: revision
|
|
||||||
value: $(params.PULL_BASE_SHA)
|
|
||||||
- name: deleteExisting
|
|
||||||
value: "true"
|
|
||||||
- name: build-image
|
|
||||||
taskRef:
|
|
||||||
name: kaniko
|
|
||||||
params:
|
|
||||||
- name: IMAGE
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: CONTEXT
|
|
||||||
value: $(params.path-to-image-context)
|
|
||||||
- name: DOCKERFILE
|
|
||||||
value: $(params.path-to-dockerfile)
|
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
|
||||||
value:
|
|
||||||
- --cache=true
|
|
||||||
- --cache-copy-layers
|
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
|
||||||
- --use-new-run # Should result in a speed-up
|
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
|
||||||
- --snapshot-mode=redo
|
|
||||||
- --skip-unused-stages=true
|
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: dockerconfig
|
|
||||||
workspace: docker-credentials
|
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
- name: rustfmt
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
runAfter:
|
|
||||||
- build-image
|
|
||||||
params:
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: cargo-fix
|
|
||||||
taskRef:
|
|
||||||
name: run-docker-image
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
- name: cargo-cache
|
|
||||||
workspace: cargo-cache
|
|
||||||
runAfter:
|
|
||||||
- rustfmt
|
|
||||||
params:
|
|
||||||
- name: command
|
|
||||||
value: ["cargo", "fix"]
|
|
||||||
- name: args
|
|
||||||
value: ["--allow-dirty"]
|
|
||||||
- name: docker-image
|
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: commit-changes
|
|
||||||
taskRef:
|
|
||||||
name: git-cli
|
|
||||||
params:
|
|
||||||
- name: GIT_USER_NAME
|
|
||||||
value: $(params.GIT_USER_NAME)
|
|
||||||
- name: GIT_USER_EMAIL
|
|
||||||
value: $(params.GIT_USER_EMAIL)
|
|
||||||
- name: GIT_SCRIPT
|
|
||||||
value: |
|
|
||||||
pwd
|
|
||||||
git config --global --add safe.directory /workspace/source
|
|
||||||
git_status=$(git status --porcelain)
|
|
||||||
if [ -n "$git_status" ]; then
|
|
||||||
git commit -a -m "CI: autofix rust code."
|
|
||||||
git push origin HEAD:$(params.PULL_BASE_REF)
|
|
||||||
else
|
|
||||||
echo "No changes to commit."
|
|
||||||
fi
|
|
||||||
workspaces:
|
|
||||||
- name: source
|
|
||||||
workspace: git-source
|
|
||||||
runAfter:
|
|
||||||
- cargo-fix
|
|
||||||
finally:
|
|
||||||
- name: report-success
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Succeeded", "Completed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has succeeded"
|
|
||||||
- name: STATE
|
|
||||||
value: success
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
- name: report-failure
|
|
||||||
when:
|
|
||||||
- input: "$(tasks.status)"
|
|
||||||
operator: in
|
|
||||||
values: ["Failed"]
|
|
||||||
taskRef:
|
|
||||||
name: gitea-set-status
|
|
||||||
params:
|
|
||||||
- name: CONTEXT
|
|
||||||
value: "$(params.JOB_NAME)"
|
|
||||||
- name: REPO_FULL_NAME
|
|
||||||
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
|
||||||
- name: GITEA_HOST_URL
|
|
||||||
value: code.fizz.buzz
|
|
||||||
- name: SHA
|
|
||||||
value: "$(tasks.fetch-repository.results.commit)"
|
|
||||||
- name: DESCRIPTION
|
|
||||||
value: "Build $(params.JOB_NAME) has failed"
|
|
||||||
- name: STATE
|
|
||||||
value: failure
|
|
||||||
- name: TARGET_URL
|
|
||||||
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
|
||||||
workspaces:
|
|
||||||
- name: git-source
|
|
||||||
- name: docker-credentials
|
|
||||||
workspaces:
|
|
||||||
- name: git-source
|
|
||||||
volumeClaimTemplate:
|
|
||||||
spec:
|
|
||||||
storageClassName: "nfs-client"
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 10Gi
|
|
||||||
subPath: rust-source
|
|
||||||
- name: cargo-cache
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: organic-cargo-cache-fmt
|
|
||||||
- name: docker-credentials
|
|
||||||
secret:
|
|
||||||
secretName: harbor-plain
|
|
||||||
serviceAccountName: build-bot
|
|
||||||
timeout: 240h0m0s
|
|
||||||
params:
|
|
||||||
- name: image-name
|
|
||||||
value: "harbor.fizz.buzz/private/organic-fmt"
|
|
||||||
- name: path-to-image-context
|
|
||||||
value: docker/cargo_fmt/
|
|
||||||
- name: path-to-dockerfile
|
|
||||||
value: docker/cargo_fmt/Dockerfile
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
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: clippy
|
|
||||||
source: "pipeline-clippy.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]+$"
|
|
||||||
701
.webhook_bridge/pipeline-build-hash.yaml
Normal file
701
.webhook_bridge/pipeline-build-hash.yaml
Normal file
@@ -0,0 +1,701 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: build
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m0s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
#############
|
||||||
|
- name: run-image-none
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args: ["--no-default-features"]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: none
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-tracing
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args: ["--no-default-features", "--features", "tracing"]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: tracing
|
||||||
|
runAfter:
|
||||||
|
- run-image-none
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-compare
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args: ["--no-default-features", "--features", "compare"]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: compare
|
||||||
|
runAfter:
|
||||||
|
- run-image-tracing
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-default
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args: []
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: default
|
||||||
|
runAfter:
|
||||||
|
- run-image-compare
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-tracing-compare
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args: ["--no-default-features", "--features", "tracing,compare"]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: tracing-compare
|
||||||
|
runAfter:
|
||||||
|
- run-image-default
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-compare-foreign
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
"--no-default-features",
|
||||||
|
"--features",
|
||||||
|
"compare,foreign_document_test",
|
||||||
|
]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: compare-foreign
|
||||||
|
runAfter:
|
||||||
|
- run-image-tracing-compare
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-all
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
"--no-default-features",
|
||||||
|
"--features",
|
||||||
|
"tracing,compare,foreign_document_test",
|
||||||
|
]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: all
|
||||||
|
runAfter:
|
||||||
|
- run-image-compare-foreign
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-wasm
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
"--target",
|
||||||
|
"wasm32-unknown-unknown",
|
||||||
|
"--profile",
|
||||||
|
"wasm",
|
||||||
|
"--bin",
|
||||||
|
"wasm",
|
||||||
|
"--no-default-features",
|
||||||
|
"--features",
|
||||||
|
"wasm",
|
||||||
|
]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: wasm
|
||||||
|
runAfter:
|
||||||
|
- run-image-all
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
- name: run-image-wasm-test
|
||||||
|
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: 60Mi
|
||||||
|
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", "build"]
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
"--bin",
|
||||||
|
"wasm_test",
|
||||||
|
"--no-default-features",
|
||||||
|
"--features",
|
||||||
|
"wasm_test",
|
||||||
|
]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: wasm-test
|
||||||
|
runAfter:
|
||||||
|
- run-image-wasm
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
#############
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
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
|
||||||
|
- name: cache-subdir
|
||||||
|
type: string
|
||||||
|
description: subPath used in the persistent volume for the cargo cache.
|
||||||
|
steptemplate:
|
||||||
|
image: alpine:3.18
|
||||||
|
name: ""
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 60Mi
|
||||||
|
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: ["ls", "$(workspaces.cargo-cache.path)"]
|
||||||
|
# command: [echo, $(params.cache-subdir)]
|
||||||
|
# command: [cargo, cache, --autoclean]
|
||||||
|
args: []
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
subPath: $(params.cache-subdir)
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
- name: cache-subdir
|
||||||
|
value: none
|
||||||
|
# matrix:
|
||||||
|
# params:
|
||||||
|
# - name: cache-subdir
|
||||||
|
# value:
|
||||||
|
# - none
|
||||||
|
# - tracing
|
||||||
|
# - compare
|
||||||
|
# - default
|
||||||
|
# - tracing-compare
|
||||||
|
# - compare-foreign
|
||||||
|
# - all
|
||||||
|
# - wasm
|
||||||
|
# - wasm-test
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: organic-cargo-cache-build
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/organic-development-wasm"
|
||||||
|
- name: target-name
|
||||||
|
value: "wasm"
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: .
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/organic_development/
|
||||||
301
.webhook_bridge/pipeline-foreign-document-test.yaml
Normal file
301
.webhook_bridge/pipeline-foreign-document-test.yaml
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: foreign-document-test
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m40s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-test
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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)"
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
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.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: organic-cargo-cache-test-foreign-document
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/organic-test-foreign-document"
|
||||||
|
- name: target-name
|
||||||
|
value: "foreign-document"
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/organic_test/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/organic_test/
|
||||||
334
.webhook_bridge/pipeline-format.yaml
Normal file
334
.webhook_bridge/pipeline-format.yaml
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-format
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m0s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-cargo-fmt
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
- name: commit-changes
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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: fluxcdbot
|
||||||
|
- name: GIT_USER_EMAIL
|
||||||
|
value: "fluxcdbot@users.noreply.github.com"
|
||||||
|
- name: GIT_SCRIPT
|
||||||
|
value: |
|
||||||
|
pwd
|
||||||
|
git config --global --add safe.directory /workspace/source
|
||||||
|
git_status=$(git status --porcelain)
|
||||||
|
if [ -n "$git_status" ]; then
|
||||||
|
git commit -a -m "CI: autofix rust code."
|
||||||
|
git push origin HEAD:$(params.PULL_BASE_REF)
|
||||||
|
else
|
||||||
|
echo "No changes to commit."
|
||||||
|
fi
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- run-cargo-fmt
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
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.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: organic-cargo-cache-fmt
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/organic-development-format"
|
||||||
|
- name: target-name
|
||||||
|
value: "format"
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/organic_development/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/organic_development/
|
||||||
313
.webhook_bridge/pipeline-rust-clippy.yaml
Normal file
313
.webhook_bridge/pipeline-rust-clippy.yaml
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-clippy
|
||||||
|
spec:
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m40s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-cargo-clippy
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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",
|
||||||
|
"clippy",
|
||||||
|
"--no-deps",
|
||||||
|
"--all-targets",
|
||||||
|
"--all-features",
|
||||||
|
"--",
|
||||||
|
"-D",
|
||||||
|
"warnings",
|
||||||
|
]
|
||||||
|
args: []
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
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.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: organic-cargo-cache-clippy
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/organic-development-clippy"
|
||||||
|
- name: target-name
|
||||||
|
value: "clippy"
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/organic_development/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/organic_development/
|
||||||
312
.webhook_bridge/pipeline-rust-test.yaml
Normal file
312
.webhook_bridge/pipeline-rust-test.yaml
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
apiVersion: tekton.dev/v1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-test
|
||||||
|
spec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m40s"
|
||||||
|
finally: "0h30m0s"
|
||||||
|
taskRunTemplate:
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
|
- name: revision
|
||||||
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
|
- name: pathInRepo
|
||||||
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
|
params:
|
||||||
|
- name: OUTPUT
|
||||||
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- "--opt"
|
||||||
|
- "target=$(params.target-name)"
|
||||||
|
- --import-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
|
- --export-cache
|
||||||
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
|
- --opt
|
||||||
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-cargo-test
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
type: string
|
||||||
|
description: Docker image to run.
|
||||||
|
default: alpine:3.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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, test]
|
||||||
|
args:
|
||||||
|
[
|
||||||
|
--no-default-features,
|
||||||
|
--features,
|
||||||
|
"compare,wasm_test",
|
||||||
|
--no-fail-fast,
|
||||||
|
--lib,
|
||||||
|
--test,
|
||||||
|
test_loader,
|
||||||
|
]
|
||||||
|
env:
|
||||||
|
- name: CARGO_TARGET_DIR
|
||||||
|
value: /target
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
resolver: git
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of 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)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
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.20
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
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: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "local-path"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: organic-cargo-cache-test
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/organic-test"
|
||||||
|
- name: target-name
|
||||||
|
value: "tester"
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/organic_test/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/organic_test/
|
||||||
31
.webhook_bridge/webhook_bridge.toml
Normal file
31
.webhook_bridge/webhook_bridge.toml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "rust-test"
|
||||||
|
source = "pipeline-rust-test.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/organic.git"
|
||||||
|
skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "foreign-document-test"
|
||||||
|
source = "pipeline-foreign-document-test.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/organic.git"
|
||||||
|
branches = [ "^main$", "^master$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "clippy"
|
||||||
|
source = "pipeline-rust-clippy.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/organic.git"
|
||||||
|
skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "format"
|
||||||
|
source = "pipeline-format.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/organic.git"
|
||||||
|
skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|
||||||
|
[[push]]
|
||||||
|
name = "build"
|
||||||
|
source = "pipeline-build-hash.yaml"
|
||||||
|
clone_uri = "git@code.fizz.buzz:talexander/organic.git"
|
||||||
|
branches = [ "^main$", "^master$" ]
|
||||||
12
Cargo.toml
12
Cargo.toml
@@ -1,8 +1,9 @@
|
|||||||
# cargo-features = ["profile-rustflags"]
|
# cargo-features = ["profile-rustflags"]
|
||||||
|
cargo-features = ["codegen-backend"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "organic"
|
name = "organic"
|
||||||
version = "0.1.13"
|
version = "0.1.16"
|
||||||
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
||||||
description = "An org-mode parser."
|
description = "An org-mode parser."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -45,12 +46,14 @@ path = "src/lib.rs"
|
|||||||
required-features = ["wasm"]
|
required-features = ["wasm"]
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
# This bin exists for development purposes only. The real target of this crate is the library.
|
||||||
name = "wasm_test"
|
name = "wasm_test"
|
||||||
path = "src/bin_wasm_test.rs"
|
path = "src/bin_wasm_test.rs"
|
||||||
required-features = ["wasm_test"]
|
required-features = ["wasm_test"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = { version = "0.3.28", optional = true }
|
futures = { version = "0.3.28", optional = true }
|
||||||
|
gloo-utils = "0.2.0"
|
||||||
nom = "7.1.1"
|
nom = "7.1.1"
|
||||||
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
||||||
opentelemetry-otlp = { version = "0.13.0", optional = true }
|
opentelemetry-otlp = { version = "0.13.0", optional = true }
|
||||||
@@ -100,3 +103,10 @@ debug = true
|
|||||||
inherits = "release"
|
inherits = "release"
|
||||||
lto = true
|
lto = true
|
||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
codegen-backend = "llvm"
|
||||||
|
opt-level = 3
|
||||||
|
|||||||
68
Makefile
68
Makefile
@@ -7,6 +7,7 @@ MAKEFLAGS += --no-builtin-rules
|
|||||||
TESTJOBS := 4
|
TESTJOBS := 4
|
||||||
OS:=$(shell uname -s)
|
OS:=$(shell uname -s)
|
||||||
RELEASEFLAGS :=
|
RELEASEFLAGS :=
|
||||||
|
WASMTARGET := bundler # or web
|
||||||
|
|
||||||
ifeq ($(OS),Linux)
|
ifeq ($(OS),Linux)
|
||||||
TESTJOBS:=$(shell nproc)
|
TESTJOBS:=$(shell nproc)
|
||||||
@@ -21,60 +22,83 @@ ifeq ($(origin .RECIPEPREFIX), undefined)
|
|||||||
endif
|
endif
|
||||||
.RECIPEPREFIX = >
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help: ## List the available make targets.
|
||||||
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build: ## Make a debug build of the project.
|
||||||
> cargo build
|
> cargo build
|
||||||
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release:
|
release: ## Make an optimized build of the project.
|
||||||
> cargo build --release $(RELEASEFLAGS)
|
> cargo build --release $(RELEASEFLAGS)
|
||||||
|
|
||||||
.PHONY: wasm
|
.PHONY: wasm
|
||||||
wasm:
|
wasm: ## Build the parser as wasm.
|
||||||
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
|
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
|
||||||
> wasm-bindgen --target web --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
|
> wasm-bindgen --target $(WASMTARGET) --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
|
||||||
|
|
||||||
.PHONY: run_wasm
|
|
||||||
run_wasm:
|
|
||||||
> cat /tmp/test.org | cargo run --profile wasm --bin wasm_test --features wasm_test
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean: ## Delete the built binaries.
|
||||||
> cargo clean
|
> cargo clean
|
||||||
|
> $(MAKE) -C docker/organic_development TARGET=builder clean
|
||||||
|
> $(MAKE) -C docker/organic_development TARGET=format clean
|
||||||
|
> $(MAKE) -C docker/organic_development TARGET=clippy clean
|
||||||
|
> $(MAKE) -C docker/organic_development TARGET=wasm clean
|
||||||
|
> $(MAKE) -C docker/organic_test TARGET=tester build
|
||||||
|
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format:
|
format: ## Format the code.
|
||||||
> $(MAKE) -C docker/cargo_fmt run
|
> cargo fmt
|
||||||
|
|
||||||
.PHONY: dockerclippy
|
.PHONY: docker_format
|
||||||
dockerclippy:
|
docker_format: ## Format the code using docker.
|
||||||
> $(MAKE) -C docker/organic_clippy run
|
> $(MAKE) -C docker/organic_development TARGET=format build
|
||||||
|
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" organic-development-format cargo fmt
|
||||||
|
|
||||||
|
.PHONY: docker_clippy
|
||||||
|
docker_clippy: ## Lint the code using docker.
|
||||||
|
> $(MAKE) -C docker/organic_development TARGET=clippy build
|
||||||
|
> docker run --rm -i -t --mount type=tmpfs,destination=/tmp -v "$(shell readlink -f .):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" organic-development-clippy cargo clippy --no-deps --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
.PHONY: clippy
|
.PHONY: clippy
|
||||||
clippy:
|
clippy: ## Lint the code.
|
||||||
> cargo clippy --no-deps --all-targets --all-features -- -D warnings
|
> cargo clippy --no-deps --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test: ## Run the test suite.
|
||||||
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
||||||
|
|
||||||
.PHONY: dockertest
|
.PHONY: doc
|
||||||
dockertest:
|
doc: ## Generate documentation.
|
||||||
> $(MAKE) -C docker/organic_test
|
> cargo doc --no-deps --open --lib --release --all-features
|
||||||
|
|
||||||
|
.PHONY: docker_test
|
||||||
|
docker_test: ## Run the test suite using docker.
|
||||||
|
> $(MAKE) -C docker/organic_test TARGET=tester build
|
||||||
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
||||||
|
|
||||||
.PHONY: buildtest
|
.PHONY: docker_wasm_test
|
||||||
buildtest:
|
docker_wasm_test: ## Run the test suite with wasm tests.
|
||||||
|
> $(MAKE) -C docker/organic_test TARGET=tester build
|
||||||
|
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test --no-default-features --features compare,wasm_test --no-fail-fast --lib --test test_loader autogen_wasm_ -- --test-threads $(TESTJOBS)
|
||||||
|
|
||||||
|
.PHONY: build_test
|
||||||
|
build_test:
|
||||||
> cargo build --no-default-features
|
> cargo build --no-default-features
|
||||||
> cargo build --no-default-features --features compare
|
> cargo build --no-default-features --features compare
|
||||||
> cargo build --no-default-features --features tracing
|
> cargo build --no-default-features --features tracing
|
||||||
> cargo build --no-default-features --features compare,tracing
|
> cargo build --no-default-features --features compare,tracing
|
||||||
> cargo build --no-default-features --features compare,foreign_document_test
|
> cargo build --no-default-features --features compare,foreign_document_test
|
||||||
> cargo build --no-default-features --features compare,tracing,foreign_document_test
|
> cargo build --no-default-features --features compare,tracing,foreign_document_test
|
||||||
|
> cargo build --target wasm32-unknown-unknown --profile wasm --bin wasm --no-default-features --features wasm
|
||||||
|
> cargo build --bin wasm_test --no-default-features --features wasm_test
|
||||||
|
|
||||||
.PHONY: foreign_document_test
|
.PHONY: foreign_document_test
|
||||||
foreign_document_test:
|
foreign_document_test:
|
||||||
> $(MAKE) -C docker/organic_test run_foreign_document_test
|
> $(MAKE) -C docker/organic_test TARGET=foreign-document build
|
||||||
|
> docker run --init --rm -i -t --read-only -v "$$(readlink -f ./):/source:ro" --mount type=tmpfs,destination=/tmp --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test-foreign-document
|
||||||
|
|
||||||
.PHONY: dockerclean
|
.PHONY: dockerclean
|
||||||
dockerclean:
|
dockerclean:
|
||||||
|
|||||||
@@ -10,17 +10,16 @@ Currently, Organic parses most documents the same as the official org-mode parse
|
|||||||
|
|
||||||
### Project Goals
|
### Project Goals
|
||||||
- We aim to provide perfect parity with the emacs org-mode parser. In that regard, any document that parses differently between Emacs and Organic is considered a bug.
|
- We aim to provide perfect parity with the emacs org-mode parser. In that regard, any document that parses differently between Emacs and Organic is considered a bug.
|
||||||
- The parser should have minimal dependencies. This should reduce effort w.r.t.: security audits, legal compliance, portability.
|
- The parser should have minimal dependencies.
|
||||||
- The parser should be usable everywhere. In the interest of getting org-mode used in as many places as possible, this parser should be usable by everyone everywhere. This means:
|
- The parser should be usable everywhere. In the interest of getting org used in as many places as possible, this parser should be usable by everyone everywhere. This means:
|
||||||
- It must have a permissive license.
|
- It must have a permissive license.
|
||||||
- We will investigate compiling to WASM. This is an important goal of the project and will definitely happen, but only after the parser has a more stable API.
|
- It compiles to both natively and to wasm.
|
||||||
- We will investigate compiling to a C library for native linking to other code. This is more of a maybe-goal for the project.
|
- We will investigate compiling to a C library for native linking to other code. This is more of a maybe-goal for the project.
|
||||||
### Project Non-Goals
|
### Project Non-Goals
|
||||||
- This project will not include an elisp engine since that would drastically increase the complexity of the code. Any features requiring an elisp engine will not be implemented (for example, Emacs supports embedded eval expressions in documents but this parser will never support that).
|
- This project will not include an elisp engine since that would drastically increase the complexity of the code. Any features requiring an elisp engine will not be implemented (for example, Emacs supports embedded eval expressions in documents but this parser will never support that).
|
||||||
- This project is exclusively an org-mode **parser**. This limits its scope to roughly the output of `(org-element-parse-buffer)`. It will not render org-mode documents in other formats like HTML or LaTeX.
|
- This project is exclusively an org-mode **parser**. This limits its scope to roughly the output of `(org-element-parse-buffer)`. It will not render org-mode documents in other formats like HTML or LaTeX.
|
||||||
### Project Maybe-Goals
|
### Project Maybe-Goals
|
||||||
- table.el support. Currently we support org-mode tables but org-mode also allows table.el tables. So far, their use in org-mode documents seems rather uncommon so this is a low-priority feature.
|
- table.el support. Currently we support org-mode tables but org-mode also allows table.el tables. So far, their use in org-mode documents seems rather uncommon so this is a low-priority feature.
|
||||||
- Document editing support. I do not anticipate any advanced editing features to make editing ergonomic, but it should be relatively easy to be able to parse an org-mode document and serialize it back into org-mode. This would enable cool features to be built on top of the library like auto-formatters. To accomplish this feature, We'd have to capture all of the various separators and whitespace that we are currently simply throwing away. This would add many additional fields to the parsed structs and it would add more noise to the parsers themselves, so I do not want to approach this feature until the parser is more complete since it would make modifications and refactoring more difficult.
|
|
||||||
### Supported Versions
|
### Supported Versions
|
||||||
This project targets the version of Emacs and Org-mode that are built into the [organic-test docker image](docker/organic_test/Dockerfile). This is newer than the version of Org-mode that shipped with Emacs 29.1. The parser itself does not depend on Emacs or Org-mode though, so this only matters for development purposes when running the automated tests that compare against upstream Org-mode.
|
This project targets the version of Emacs and Org-mode that are built into the [organic-test docker image](docker/organic_test/Dockerfile). This is newer than the version of Org-mode that shipped with Emacs 29.1. The parser itself does not depend on Emacs or Org-mode though, so this only matters for development purposes when running the automated tests that compare against upstream Org-mode.
|
||||||
|
|
||||||
|
|||||||
2
build.rs
2
build.rs
@@ -26,7 +26,7 @@ fn main() {
|
|||||||
dir_entry.file_type().is_file()
|
dir_entry.file_type().is_file()
|
||||||
&& Path::new(dir_entry.file_name())
|
&& Path::new(dir_entry.file_name())
|
||||||
.extension()
|
.extension()
|
||||||
.map(|ext| ext.to_ascii_lowercase() == "org")
|
.map(|ext| ext.eq_ignore_ascii_case("org"))
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
Err(_) => true,
|
Err(_) => true,
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
FROM rustlang/rust:nightly-alpine3.17
|
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev
|
|
||||||
RUN rustup component add rustfmt
|
|
||||||
|
|
||||||
ENTRYPOINT ["cargo", "fmt"]
|
|
||||||
@@ -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)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
FROM rustlang/rust:nightly-alpine3.17
|
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev
|
|
||||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
|
||||||
RUN rustup target add wasm32-unknown-unknown
|
|
||||||
|
|
||||||
ENTRYPOINT ["cargo", "build"]
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
IMAGE_NAME:=organic-build
|
|
||||||
# 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 cargo-cache
|
|
||||||
|
|
||||||
# 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 --mount source=cargo-cache,target=/usr/local/cargo/registry $(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 --mount source=cargo-cache,target=/usr/local/cargo/registry $(IMAGE_NAME)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM rustlang/rust:nightly-alpine3.17
|
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev
|
|
||||||
|
|
||||||
ENTRYPOINT ["cargo", "clippy", "--no-deps", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
|
||||||
@@ -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 --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)
|
|
||||||
20
docker/organic_development/Dockerfile
Normal file
20
docker/organic_development/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG ALPINE_VERSION="3.20"
|
||||||
|
|
||||||
|
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache musl-dev
|
||||||
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||||
|
RUN rustup component add rustc-codegen-cranelift
|
||||||
|
|
||||||
|
FROM builder AS format
|
||||||
|
|
||||||
|
RUN rustup component add rustfmt
|
||||||
|
|
||||||
|
FROM builder AS clippy
|
||||||
|
|
||||||
|
RUN rustup component add clippy
|
||||||
|
|
||||||
|
FROM builder AS wasm
|
||||||
|
|
||||||
|
RUN rustup target add wasm32-unknown-unknown
|
||||||
36
docker/organic_development/Makefile
Normal file
36
docker/organic_development/Makefile
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
SHELL := bash
|
||||||
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
|
||||||
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
TARGET := builder
|
||||||
|
IMAGE_NAME := organic-development
|
||||||
|
ifneq ($(TARGET),builder)
|
||||||
|
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: ## Build the docker image.
|
||||||
|
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile .
|
||||||
|
> docker volume create organic-cargo-registry
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
|
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
|
||||||
|
shell: build
|
||||||
|
> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" $(IMAGE_NAME)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: ## Remove the docker image and volume.
|
||||||
|
> docker rmi $(IMAGE_NAME)
|
||||||
|
> docker volume rm organic-cargo-registry
|
||||||
@@ -1,10 +1,25 @@
|
|||||||
FROM alpine:3.17 AS build
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG ALPINE_VERSION="3.20"
|
||||||
|
|
||||||
|
# ARG EMACS_REPO=https://git.savannah.gnu.org/git/emacs.git
|
||||||
|
ARG EMACS_REPO=https://code.fizz.buzz/mirror/emacs.git
|
||||||
|
|
||||||
|
ARG EMACS_VERSION=emacs-29.1
|
||||||
|
|
||||||
|
# ARG ORG_MODE_REPO=https://git.savannah.gnu.org/git/emacs/org-mode.git
|
||||||
|
ARG ORG_MODE_REPO=https://code.fizz.buzz/mirror/org-mode.git
|
||||||
|
|
||||||
|
ARG ORG_VERSION=abf5156096c06ee5aa05795c3dc5a065f76ada97
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:$ALPINE_VERSION AS build
|
||||||
RUN apk add --no-cache build-base musl-dev git autoconf make texinfo gnutls-dev ncurses-dev gawk libgccjit-dev
|
RUN apk add --no-cache build-base musl-dev git autoconf make texinfo gnutls-dev ncurses-dev gawk libgccjit-dev
|
||||||
|
|
||||||
|
|
||||||
FROM build AS build-emacs
|
FROM build AS build-emacs
|
||||||
ARG EMACS_VERSION=emacs-29.1
|
ARG EMACS_VERSION
|
||||||
RUN git clone --depth 1 --branch $EMACS_VERSION https://git.savannah.gnu.org/git/emacs.git /root/emacs
|
ARG EMACS_REPO
|
||||||
|
RUN git clone --depth 1 --branch $EMACS_VERSION $EMACS_REPO /root/emacs
|
||||||
WORKDIR /root/emacs
|
WORKDIR /root/emacs
|
||||||
RUN mkdir /root/dist
|
RUN mkdir /root/dist
|
||||||
RUN ./autogen.sh
|
RUN ./autogen.sh
|
||||||
@@ -14,23 +29,25 @@ RUN make DESTDIR="/root/dist" install
|
|||||||
|
|
||||||
|
|
||||||
FROM build AS build-org-mode
|
FROM build AS build-org-mode
|
||||||
ARG ORG_VERSION=abf5156096c06ee5aa05795c3dc5a065f76ada97
|
ARG ORG_VERSION
|
||||||
COPY --from=build-emacs /root/dist/ /
|
ARG ORG_MODE_REPO
|
||||||
|
COPY --link --from=build-emacs /root/dist/ /
|
||||||
RUN mkdir /root/dist
|
RUN mkdir /root/dist
|
||||||
# Savannah does not allow fetching specific revisions, so we're going to have to put unnecessary load on their server by cloning main and then checking out the revision we want.
|
# Savannah does not allow fetching specific revisions, so we're going to have to put unnecessary load on their server by cloning main and then checking out the revision we want.
|
||||||
RUN git clone https://git.savannah.gnu.org/git/emacs/org-mode.git /root/org-mode && git -C /root/org-mode checkout $ORG_VERSION
|
RUN git clone $ORG_MODE_REPO /root/org-mode && git -C /root/org-mode checkout $ORG_VERSION
|
||||||
# RUN mkdir /root/org-mode && git -C /root/org-mode init --initial-branch=main && git -C /root/org-mode remote add origin https://git.savannah.gnu.org/git/emacs/org-mode.git && git -C /root/org-mode fetch origin $ORG_VERSION && git -C /root/org-mode checkout FETCH_HEAD
|
# RUN mkdir /root/org-mode && git -C /root/org-mode init --initial-branch=main && git -C /root/org-mode remote add origin $ORG_REPO && git -C /root/org-mode fetch origin $ORG_VERSION && git -C /root/org-mode checkout FETCH_HEAD
|
||||||
WORKDIR /root/org-mode
|
WORKDIR /root/org-mode
|
||||||
RUN make compile
|
RUN make compile
|
||||||
RUN make DESTDIR="/root/dist" install
|
RUN make DESTDIR="/root/dist" install
|
||||||
|
|
||||||
|
|
||||||
FROM rustlang/rust:nightly-alpine3.17 AS tester
|
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS tester
|
||||||
ENV LANG=en_US.UTF-8
|
ENV LANG=en_US.UTF-8
|
||||||
RUN apk add --no-cache musl-dev ncurses gnutls libgccjit
|
RUN apk add --no-cache musl-dev ncurses gnutls libgccjit
|
||||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||||
COPY --from=build-emacs /root/dist/ /
|
RUN rustup component add rustc-codegen-cranelift
|
||||||
COPY --from=build-org-mode /root/dist/ /
|
COPY --link --from=build-emacs /root/dist/ /
|
||||||
|
COPY --link --from=build-org-mode /root/dist/ /
|
||||||
|
|
||||||
ENTRYPOINT ["cargo", "test"]
|
ENTRYPOINT ["cargo", "test"]
|
||||||
|
|
||||||
@@ -100,13 +117,13 @@ RUN mkdir -p $LITERATE_BUILD_EMACS_PATH && git -C $LITERATE_BUILD_EMACS_PATH ini
|
|||||||
# unused/aws.org contains invalid paths for setupfile which causes both upstream org-mode and Organic to error out.
|
# unused/aws.org contains invalid paths for setupfile which causes both upstream org-mode and Organic to error out.
|
||||||
RUN rm $LITERATE_BUILD_EMACS_PATH/unused/aws.org
|
RUN rm $LITERATE_BUILD_EMACS_PATH/unused/aws.org
|
||||||
|
|
||||||
FROM tester as foreign-document-test
|
FROM tester as foreign-document
|
||||||
RUN apk add --no-cache bash coreutils
|
RUN apk add --no-cache bash coreutils
|
||||||
RUN mkdir /foreign_documents
|
RUN mkdir /foreign_documents
|
||||||
COPY --from=foreign-document-gather /foreign_documents/howardabrams /foreign_documents/howardabrams
|
COPY --link --from=foreign-document-gather /foreign_documents/howardabrams /foreign_documents/howardabrams
|
||||||
COPY --from=foreign-document-gather /foreign_documents/doomemacs /foreign_documents/doomemacs
|
COPY --link --from=foreign-document-gather /foreign_documents/doomemacs /foreign_documents/doomemacs
|
||||||
COPY --from=foreign-document-gather /foreign_documents/worg /foreign_documents/worg
|
COPY --link --from=foreign-document-gather /foreign_documents/worg /foreign_documents/worg
|
||||||
COPY --from=foreign-document-gather /foreign_documents/literate_build_emacs /foreign_documents/literate_build_emacs
|
COPY --link --from=foreign-document-gather /foreign_documents/literate_build_emacs /foreign_documents/literate_build_emacs
|
||||||
COPY --from=build-org-mode /root/org-mode /foreign_documents/org-mode
|
COPY --link --from=build-org-mode /root/org-mode /foreign_documents/org-mode
|
||||||
COPY --from=build-emacs /root/emacs /foreign_documents/emacs
|
COPY --link --from=build-emacs /root/emacs /foreign_documents/emacs
|
||||||
ENTRYPOINT ["cargo", "run", "--bin", "foreign_document_test", "--features", "compare,foreign_document_test", "--profile", "release-lto"]
|
ENTRYPOINT ["cargo", "run", "--bin", "foreign_document_test", "--features", "compare,foreign_document_test", "--profile", "release-lto"]
|
||||||
|
|||||||
@@ -1,44 +1,36 @@
|
|||||||
IMAGE_NAME:=organic-test
|
SHELL := bash
|
||||||
# REMOTE_REPO:=harbor.fizz.buzz/private
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
|
||||||
.PHONY: all
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
all: build push
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
TARGET := tester
|
||||||
|
IMAGE_NAME := organic-test
|
||||||
|
ifneq ($(TARGET),tester)
|
||||||
|
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build: ## Build the docker image.
|
||||||
docker build -t $(IMAGE_NAME) -f Dockerfile --target tester .
|
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile .
|
||||||
|
> docker volume create organic-cargo-registry
|
||||||
.PHONY: build_foreign_document_test
|
|
||||||
build_foreign_document_test:
|
|
||||||
docker build -t $(IMAGE_NAME)-foreign-document -f Dockerfile --target foreign-document-test .
|
|
||||||
|
|
||||||
.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
|
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
run: build
|
|
||||||
docker run --rm --init --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) --no-default-features --features compare --no-fail-fast --lib --test test_loader
|
|
||||||
|
|
||||||
.PHONY: shell
|
.PHONY: shell
|
||||||
|
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
|
||||||
shell: build
|
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)
|
> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" $(IMAGE_NAME)
|
||||||
|
|
||||||
.PHONY: run_foreign_document_test
|
.PHONY: clean
|
||||||
run_foreign_document_test: build_foreign_document_test
|
clean: ## Remove the docker image and volume.
|
||||||
docker run --rm --init --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)-foreign-document
|
> docker rmi $(IMAGE_NAME)
|
||||||
|
> docker volume rm organic-cargo-registry
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
[[file:simple.org::2]]
|
||||||
1
org_mode_samples/object/regular_link/tramp_link.org
Normal file
1
org_mode_samples/object/regular_link/tramp_link.org
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[[/ssh:admin@test.example:important/file.pdf]]
|
||||||
111
scripts/run_docker_wasm_compare.bash
Executable file
111
scripts/run_docker_wasm_compare.bash
Executable file
@@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: ${SHELL:="NO"} # or YES to launch a shell instead of running the test
|
||||||
|
: ${TRACE:="NO"} # or YES to send traces to jaeger
|
||||||
|
: ${BACKTRACE:="NO"} # or YES to print a rust backtrace when panicking
|
||||||
|
: ${NO_COLOR:=""} # Set to anything to disable color output
|
||||||
|
: ${PROFILE:="debug"}
|
||||||
|
|
||||||
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
MAKE=$(command -v gmake || command -v make)
|
||||||
|
|
||||||
|
############## Setup #########################
|
||||||
|
|
||||||
|
function die {
|
||||||
|
local status_code="$1"
|
||||||
|
shift
|
||||||
|
(>&2 echo "${@}")
|
||||||
|
exit "$status_code"
|
||||||
|
}
|
||||||
|
|
||||||
|
function log {
|
||||||
|
(>&2 echo "${@}")
|
||||||
|
}
|
||||||
|
|
||||||
|
############## Program #########################
|
||||||
|
|
||||||
|
function main {
|
||||||
|
build_container
|
||||||
|
launch_container "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_container {
|
||||||
|
$MAKE -C "$DIR/../docker/organic_test"
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch_container {
|
||||||
|
local additional_flags=()
|
||||||
|
local features=(wasm_test)
|
||||||
|
|
||||||
|
if [ "$NO_COLOR" != "" ]; then
|
||||||
|
additional_flags+=(--env "NO_COLOR=$NO_COLOR")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TRACE" = "YES" ]; then
|
||||||
|
# We use the host network so it can talk to jaeger hosted at 127.0.0.1
|
||||||
|
additional_flags+=(--network=host --env RUST_LOG=debug)
|
||||||
|
features+=(tracing)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SHELL" != "YES" ]; then
|
||||||
|
additional_flags+=(--read-only)
|
||||||
|
else
|
||||||
|
additional_flags+=(-t)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BACKTRACE" = "YES" ]; then
|
||||||
|
additional_flags+=(--env RUST_BACKTRACE=full)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SHELL" = "YES" ]; then
|
||||||
|
exec docker run "${additional_flags[@]}" --init --rm -i --mount type=tmpfs,destination=/tmp -v "/:/input:ro" -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test /bin/sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
local features_joined
|
||||||
|
features_joined=$(IFS=","; echo "${features[*]}")
|
||||||
|
|
||||||
|
local build_flags=()
|
||||||
|
if [ "$PROFILE" = "dev" ] || [ "$PROFILE" = "debug" ]; then
|
||||||
|
PROFILE="debug"
|
||||||
|
else
|
||||||
|
build_flags+=(--profile "$PROFILE")
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
# If we passed in args, we need to forward them along
|
||||||
|
for path in "${@}"; do
|
||||||
|
local full_path
|
||||||
|
full_path=$($REALPATH "$path")
|
||||||
|
init_script=$(cat <<EOF
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
|
cargo build --bin wasm_test --no-default-features --features "$features_joined" ${build_flags[@]}
|
||||||
|
exec /target/${PROFILE}/wasm_test "/input${full_path}"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
docker run "${additional_flags[@]}" --init --rm -i --mount type=tmpfs,destination=/tmp -v "/:/input:ro" -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test sh -c "$init_script"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
local current_directory init_script
|
||||||
|
current_directory=$(pwd)
|
||||||
|
init_script=$(cat <<EOF
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
|
cargo build --bin wasm_test --no-default-features --features "$features_joined" ${build_flags[@]}
|
||||||
|
cd /input${current_directory}
|
||||||
|
exec /target/${PROFILE}/wasm_test
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
docker run "${additional_flags[@]}" --init --rm -i --mount type=tmpfs,destination=/tmp -v "/:/input:ro" -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test sh -c "$init_script"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
@@ -1,28 +1,8 @@
|
|||||||
use organic::parser::parse_with_settings;
|
|
||||||
use organic::settings::GlobalSettings;
|
|
||||||
use organic::wasm::ParseResult;
|
|
||||||
use organic::wasm::ToWasm;
|
|
||||||
use organic::wasm::ToWasmContext;
|
|
||||||
use wasm_bindgen::prelude::wasm_bindgen;
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
||||||
let rust_parsed = match parse_with_settings(org_contents, &GlobalSettings::default()) {
|
organic::wasm_cli::parse_org(org_contents)
|
||||||
Ok(document) => document,
|
|
||||||
Err(err) => {
|
|
||||||
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let to_wasm_context = ToWasmContext::new(org_contents);
|
|
||||||
let wasm_document = match rust_parsed.to_wasm(to_wasm_context) {
|
|
||||||
Ok(document) => document,
|
|
||||||
Err(err) => {
|
|
||||||
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
serde_wasm_bindgen::to_value(&ParseResult::Success(wasm_document)).unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use organic::wasm_test::wasm_run_anonymous_compare;
|
use organic::wasm_test::wasm_run_anonymous_compare;
|
||||||
|
use organic::wasm_test::wasm_run_compare_on_file;
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use crate::init_tracing::init_telemetry;
|
use crate::init_tracing::init_telemetry;
|
||||||
@@ -42,14 +43,13 @@ async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
todo!()
|
for arg in args {
|
||||||
// for arg in args {
|
if wasm_run_compare_on_file(arg).await? {
|
||||||
// if run_compare_on_file(arg).await? {
|
} else {
|
||||||
// } else {
|
Err("Diff results do not match.")?;
|
||||||
// Err("Diff results do not match.")?;
|
}
|
||||||
// }
|
}
|
||||||
// }
|
Ok(())
|
||||||
// Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::compare::diff::compare_document;
|
use crate::compare::diff::compare_document;
|
||||||
use crate::compare::diff::DiffResult;
|
|
||||||
use crate::compare::sexp::sexp;
|
|
||||||
use crate::context::GlobalSettings;
|
use crate::context::GlobalSettings;
|
||||||
use crate::context::LocalFileAccessInterface;
|
use crate::context::LocalFileAccessInterface;
|
||||||
use crate::parser::parse_file_with_settings;
|
use crate::parser::parse_file_with_settings;
|
||||||
use crate::parser::parse_with_settings;
|
use crate::parser::parse_with_settings;
|
||||||
use crate::util::emacs_parse_anonymous_org_document;
|
use crate::util::cli::emacs_parse_anonymous_org_document;
|
||||||
use crate::util::emacs_parse_file_org_document;
|
use crate::util::cli::emacs_parse_file_org_document;
|
||||||
use crate::util::foreground_color;
|
use crate::util::cli::print_versions;
|
||||||
use crate::util::print_versions;
|
use crate::util::elisp::sexp;
|
||||||
use crate::util::reset_color;
|
use crate::util::terminal::foreground_color;
|
||||||
|
use crate::util::terminal::reset_color;
|
||||||
|
|
||||||
pub async fn run_anonymous_compare<P: AsRef<str>>(
|
pub async fn run_anonymous_compare<P: AsRef<str>>(
|
||||||
org_contents: P,
|
org_contents: P,
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ use super::diff::artificial_owned_diff_scope;
|
|||||||
use super::diff::compare_ast_node;
|
use super::diff::compare_ast_node;
|
||||||
use super::diff::DiffEntry;
|
use super::diff::DiffEntry;
|
||||||
use super::diff::DiffStatus;
|
use super::diff::DiffStatus;
|
||||||
use super::sexp::unquote;
|
|
||||||
use super::sexp::Token;
|
|
||||||
use super::util::get_property;
|
use super::util::get_property;
|
||||||
use super::util::get_property_numeric;
|
use super::util::get_property_numeric;
|
||||||
use super::util::get_property_quoted_string;
|
use super::util::get_property_quoted_string;
|
||||||
@@ -20,6 +18,8 @@ use crate::types::CharOffsetInLine;
|
|||||||
use crate::types::LineNumber;
|
use crate::types::LineNumber;
|
||||||
use crate::types::RetainLabels;
|
use crate::types::RetainLabels;
|
||||||
use crate::types::SwitchNumberLines;
|
use crate::types::SwitchNumberLines;
|
||||||
|
use crate::util::elisp::unquote;
|
||||||
|
use crate::util::elisp::Token;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) enum EmacsField<'s> {
|
pub(crate) enum EmacsField<'s> {
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ use super::compare_field::compare_property_retain_labels;
|
|||||||
use super::compare_field::compare_property_set_of_quoted_string;
|
use super::compare_field::compare_property_set_of_quoted_string;
|
||||||
use super::compare_field::compare_property_single_ast_node;
|
use super::compare_field::compare_property_single_ast_node;
|
||||||
use super::compare_field::compare_property_unquoted_atom;
|
use super::compare_field::compare_property_unquoted_atom;
|
||||||
use super::elisp_fact::ElispFact;
|
|
||||||
use super::elisp_fact::GetElispFact;
|
|
||||||
use super::sexp::unquote;
|
|
||||||
use super::sexp::Token;
|
|
||||||
use super::util::affiliated_keywords_names;
|
use super::util::affiliated_keywords_names;
|
||||||
use super::util::assert_no_children;
|
use super::util::assert_no_children;
|
||||||
use super::util::compare_additional_properties;
|
use super::util::compare_additional_properties;
|
||||||
@@ -109,8 +105,12 @@ use crate::types::Verbatim;
|
|||||||
use crate::types::VerseBlock;
|
use crate::types::VerseBlock;
|
||||||
use crate::types::WarningDelayType;
|
use crate::types::WarningDelayType;
|
||||||
use crate::types::Year;
|
use crate::types::Year;
|
||||||
use crate::util::foreground_color;
|
use crate::util::elisp::unquote;
|
||||||
use crate::util::reset_color;
|
use crate::util::elisp::Token;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
|
use crate::util::elisp_fact::GetElispFact;
|
||||||
|
use crate::util::terminal::foreground_color;
|
||||||
|
use crate::util::terminal::reset_color;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum DiffEntry<'b, 's> {
|
pub enum DiffEntry<'b, 's> {
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
mod compare;
|
mod compare;
|
||||||
mod compare_field;
|
mod compare_field;
|
||||||
mod diff;
|
mod diff;
|
||||||
mod elisp_fact;
|
|
||||||
mod macros;
|
mod macros;
|
||||||
mod sexp;
|
|
||||||
mod util;
|
mod util;
|
||||||
pub use compare::run_anonymous_compare;
|
pub use compare::run_anonymous_compare;
|
||||||
pub use compare::run_anonymous_compare_with_settings;
|
pub use compare::run_anonymous_compare_with_settings;
|
||||||
@@ -12,8 +10,3 @@ pub use compare::run_compare_on_file;
|
|||||||
pub use compare::run_compare_on_file_with_settings;
|
pub use compare::run_compare_on_file_with_settings;
|
||||||
pub use compare::silent_anonymous_compare;
|
pub use compare::silent_anonymous_compare;
|
||||||
pub use compare::silent_compare_on_file;
|
pub use compare::silent_compare_on_file;
|
||||||
pub(crate) use compare_field::EmacsField;
|
|
||||||
pub(crate) use elisp_fact::ElispFact;
|
|
||||||
pub use sexp::sexp;
|
|
||||||
pub use sexp::Token;
|
|
||||||
pub(crate) use util::get_property_quoted_string;
|
|
||||||
|
|||||||
@@ -8,14 +8,15 @@ use super::compare_field::compare_property_quoted_string;
|
|||||||
use super::compare_field::ComparePropertiesResult;
|
use super::compare_field::ComparePropertiesResult;
|
||||||
use super::diff::DiffEntry;
|
use super::diff::DiffEntry;
|
||||||
use super::diff::DiffStatus;
|
use super::diff::DiffStatus;
|
||||||
use super::elisp_fact::GetElispFact;
|
|
||||||
use super::sexp::Token;
|
|
||||||
use crate::compare::diff::compare_ast_node;
|
use crate::compare::diff::compare_ast_node;
|
||||||
use crate::compare::sexp::unquote;
|
|
||||||
use crate::types::AffiliatedKeywordValue;
|
use crate::types::AffiliatedKeywordValue;
|
||||||
use crate::types::AstNode;
|
use crate::types::AstNode;
|
||||||
use crate::types::GetAffiliatedKeywords;
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::StandardProperties;
|
use crate::types::StandardProperties;
|
||||||
|
use crate::util::elisp::get_emacs_standard_properties;
|
||||||
|
use crate::util::elisp::unquote;
|
||||||
|
use crate::util::elisp::Token;
|
||||||
|
use crate::util::elisp_fact::GetElispFact;
|
||||||
|
|
||||||
/// Check if the child string slice is a slice of the parent string slice.
|
/// Check if the child string slice is a slice of the parent string slice.
|
||||||
fn is_slice_of(parent: &str, child: &str) -> bool {
|
fn is_slice_of(parent: &str, child: &str) -> bool {
|
||||||
@@ -145,80 +146,6 @@ fn assert_post_blank<'b, 's, S: StandardProperties<'s> + ?Sized>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EmacsStandardProperties {
|
|
||||||
begin: Option<usize>,
|
|
||||||
#[allow(dead_code)]
|
|
||||||
post_affiliated: Option<usize>,
|
|
||||||
#[allow(dead_code)]
|
|
||||||
contents_begin: Option<usize>,
|
|
||||||
#[allow(dead_code)]
|
|
||||||
contents_end: Option<usize>,
|
|
||||||
end: Option<usize>,
|
|
||||||
#[allow(dead_code)]
|
|
||||||
post_blank: Option<usize>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_emacs_standard_properties(
|
|
||||||
emacs: &Token<'_>,
|
|
||||||
) -> Result<EmacsStandardProperties, Box<dyn std::error::Error>> {
|
|
||||||
let children = emacs.as_list()?;
|
|
||||||
let attributes_child = children.get(1).ok_or("Should have an attributes child.")?;
|
|
||||||
let attributes_map = attributes_child.as_map()?;
|
|
||||||
let standard_properties = attributes_map.get(":standard-properties");
|
|
||||||
Ok(if standard_properties.is_some() {
|
|
||||||
let mut std_props = standard_properties
|
|
||||||
.expect("if statement proves its Some")
|
|
||||||
.as_vector()?
|
|
||||||
.iter();
|
|
||||||
let begin = maybe_token_to_usize(std_props.next())?;
|
|
||||||
let post_affiliated = maybe_token_to_usize(std_props.next())?;
|
|
||||||
let contents_begin = maybe_token_to_usize(std_props.next())?;
|
|
||||||
let contents_end = maybe_token_to_usize(std_props.next())?;
|
|
||||||
let end = maybe_token_to_usize(std_props.next())?;
|
|
||||||
let post_blank = maybe_token_to_usize(std_props.next())?;
|
|
||||||
EmacsStandardProperties {
|
|
||||||
begin,
|
|
||||||
post_affiliated,
|
|
||||||
contents_begin,
|
|
||||||
contents_end,
|
|
||||||
end,
|
|
||||||
post_blank,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let begin = maybe_token_to_usize(attributes_map.get(":begin").copied())?;
|
|
||||||
let end = maybe_token_to_usize(attributes_map.get(":end").copied())?;
|
|
||||||
let contents_begin = maybe_token_to_usize(attributes_map.get(":contents-begin").copied())?;
|
|
||||||
let contents_end = maybe_token_to_usize(attributes_map.get(":contents-end").copied())?;
|
|
||||||
let post_blank = maybe_token_to_usize(attributes_map.get(":post-blank").copied())?;
|
|
||||||
let post_affiliated =
|
|
||||||
maybe_token_to_usize(attributes_map.get(":post-affiliated").copied())?;
|
|
||||||
EmacsStandardProperties {
|
|
||||||
begin,
|
|
||||||
post_affiliated,
|
|
||||||
contents_begin,
|
|
||||||
contents_end,
|
|
||||||
end,
|
|
||||||
post_blank,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn maybe_token_to_usize(
|
|
||||||
token: Option<&Token<'_>>,
|
|
||||||
) -> Result<Option<usize>, Box<dyn std::error::Error>> {
|
|
||||||
Ok(token
|
|
||||||
.map(|token| token.as_atom())
|
|
||||||
.map_or(Ok(None), |r| r.map(Some))?
|
|
||||||
.and_then(|val| {
|
|
||||||
if val == "nil" {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(val.parse::<usize>())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.map_or(Ok(None), |r| r.map(Some))?)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a named property from the emacs token.
|
/// Get a named property from the emacs token.
|
||||||
///
|
///
|
||||||
/// Returns Ok(None) if value is nil or absent.
|
/// Returns Ok(None) if value is nil or absent.
|
||||||
|
|||||||
@@ -71,9 +71,7 @@ pub struct EntityDefinition<'a> {
|
|||||||
|
|
||||||
impl<'g, 's> GlobalSettings<'g, 's> {
|
impl<'g, 's> GlobalSettings<'g, 's> {
|
||||||
fn new() -> GlobalSettings<'g, 's> {
|
fn new() -> GlobalSettings<'g, 's> {
|
||||||
debug_assert!(
|
debug_assert!(DEFAULT_ORG_ENTITIES.is_sorted_by(|a, b| a.name.len() >= b.name.len()));
|
||||||
DEFAULT_ORG_ENTITIES.is_sorted_by(|a, b| b.name.len().partial_cmp(&a.name.len()))
|
|
||||||
);
|
|
||||||
GlobalSettings {
|
GlobalSettings {
|
||||||
radio_targets: Vec::new(),
|
radio_targets: Vec::new(),
|
||||||
file_access: &LocalFileAccessInterface {
|
file_access: &LocalFileAccessInterface {
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ pub(crate) type Res<T, U> = IResult<T, U, CustomError>;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CustomError {
|
pub enum CustomError {
|
||||||
Static(&'static str),
|
Static(#[allow(dead_code)] &'static str),
|
||||||
IO(std::io::Error),
|
IO(#[allow(dead_code)] std::io::Error),
|
||||||
Parser(ErrorKind),
|
Parser(#[allow(dead_code)] ErrorKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: std::fmt::Debug> ParseError<I> for CustomError {
|
impl<I: std::fmt::Debug> ParseError<I> for CustomError {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub(crate) fn record_event(event_type: EventType, input: OrgSource<'_>) {
|
|||||||
*db.entry(key).or_insert(0) += 1;
|
*db.entry(key).or_insert(0) += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report(original_document: &str) {
|
pub(crate) fn report(original_document: &str) {
|
||||||
let mut db = GLOBAL_DATA.lock().unwrap();
|
let mut db = GLOBAL_DATA.lock().unwrap();
|
||||||
let db = db.get_or_insert_with(HashMap::new);
|
let db = db.get_or_insert_with(HashMap::new);
|
||||||
let mut results: Vec<_> = db.iter().collect();
|
let mut results: Vec<_> = db.iter().collect();
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ mod database;
|
|||||||
mod event_type;
|
mod event_type;
|
||||||
|
|
||||||
pub(crate) use database::record_event;
|
pub(crate) use database::record_event;
|
||||||
pub use database::report;
|
pub(crate) use database::report;
|
||||||
pub(crate) use event_type::EventType;
|
pub(crate) use event_type::EventType;
|
||||||
|
|||||||
17
src/lib.rs
17
src/lib.rs
@@ -1,27 +1,30 @@
|
|||||||
#![feature(exit_status_error)]
|
#![feature(exit_status_error)]
|
||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
#![feature(path_file_prefix)]
|
#![feature(path_file_prefix)]
|
||||||
#![feature(is_sorted)]
|
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
|
#![feature(iter_intersperse)]
|
||||||
|
#![feature(exact_size_is_empty)]
|
||||||
// TODO: #![warn(missing_docs)]
|
// TODO: #![warn(missing_docs)]
|
||||||
#![allow(clippy::bool_assert_comparison)] // Sometimes you want the long form because its easier to see at a glance.
|
#![allow(clippy::bool_assert_comparison)] // Sometimes you want the long form because its easier to see at a glance.
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
// TODO: I only include compare to use some shared stuff like sexp and DiffResult. Ideally, this would be moved to a shared module.
|
#[cfg(feature = "compare")]
|
||||||
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
|
||||||
pub mod compare;
|
pub mod compare;
|
||||||
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
pub mod parse_cli;
|
||||||
pub mod util;
|
#[cfg(any(feature = "compare", feature = "wasm", feature = "wasm_test"))]
|
||||||
|
mod util;
|
||||||
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
||||||
pub mod wasm;
|
mod wasm;
|
||||||
|
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
||||||
|
pub mod wasm_cli;
|
||||||
#[cfg(feature = "wasm_test")]
|
#[cfg(feature = "wasm_test")]
|
||||||
pub mod wasm_test;
|
pub mod wasm_test;
|
||||||
|
|
||||||
mod context;
|
mod context;
|
||||||
mod error;
|
mod error;
|
||||||
#[cfg(feature = "event_count")]
|
#[cfg(feature = "event_count")]
|
||||||
pub mod event_count;
|
mod event_count;
|
||||||
mod iter;
|
mod iter;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|||||||
62
src/main.rs
62
src/main.rs
@@ -1,12 +1,4 @@
|
|||||||
#![feature(round_char_boundary)]
|
use organic::parse_cli::main_body;
|
||||||
#![feature(exact_size_is_empty)]
|
|
||||||
use std::io::Read;
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use ::organic::parser::parse;
|
|
||||||
use organic::parser::parse_with_settings;
|
|
||||||
use organic::settings::GlobalSettings;
|
|
||||||
use organic::settings::LocalFileAccessInterface;
|
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use crate::init_tracing::init_telemetry;
|
use crate::init_tracing::init_telemetry;
|
||||||
@@ -30,55 +22,3 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
main_body_result
|
main_body_result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
||||||
fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let args = std::env::args().skip(1);
|
|
||||||
if args.is_empty() {
|
|
||||||
let org_contents = read_stdin_to_string()?;
|
|
||||||
run_anonymous_parse(org_contents)
|
|
||||||
} else {
|
|
||||||
for arg in args {
|
|
||||||
run_parse_on_file(arg)?
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_stdin_to_string() -> Result<String, Box<dyn std::error::Error>> {
|
|
||||||
let mut stdin_contents = String::new();
|
|
||||||
std::io::stdin()
|
|
||||||
.lock()
|
|
||||||
.read_to_string(&mut stdin_contents)?;
|
|
||||||
Ok(stdin_contents)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_anonymous_parse<P: AsRef<str>>(org_contents: P) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let org_contents = org_contents.as_ref();
|
|
||||||
let rust_parsed = parse(org_contents)?;
|
|
||||||
println!("{:#?}", rust_parsed);
|
|
||||||
#[cfg(feature = "event_count")]
|
|
||||||
organic::event_count::report(org_contents);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let org_path = org_path.as_ref();
|
|
||||||
let parent_directory = org_path
|
|
||||||
.parent()
|
|
||||||
.ok_or("Should be contained inside a directory.")?;
|
|
||||||
let org_contents = std::fs::read_to_string(org_path)?;
|
|
||||||
let org_contents = org_contents.as_str();
|
|
||||||
let file_access_interface = LocalFileAccessInterface {
|
|
||||||
working_directory: Some(parent_directory.to_path_buf()),
|
|
||||||
};
|
|
||||||
let global_settings = GlobalSettings {
|
|
||||||
file_access: &file_access_interface,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let rust_parsed = parse_with_settings(org_contents, &global_settings)?;
|
|
||||||
println!("{:#?}", rust_parsed);
|
|
||||||
#[cfg(feature = "event_count")]
|
|
||||||
organic::event_count::report(org_contents);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|||||||
59
src/parse_cli/mod.rs
Normal file
59
src/parse_cli/mod.rs
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
use std::io::Read;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use crate::parser::parse;
|
||||||
|
use crate::parser::parse_with_settings;
|
||||||
|
use crate::settings::GlobalSettings;
|
||||||
|
use crate::settings::LocalFileAccessInterface;
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
pub fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let args = std::env::args().skip(1);
|
||||||
|
if args.is_empty() {
|
||||||
|
let org_contents = read_stdin_to_string()?;
|
||||||
|
run_anonymous_parse(org_contents)
|
||||||
|
} else {
|
||||||
|
for arg in args {
|
||||||
|
run_parse_on_file(arg)?
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_stdin_to_string() -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
let mut stdin_contents = String::new();
|
||||||
|
std::io::stdin()
|
||||||
|
.lock()
|
||||||
|
.read_to_string(&mut stdin_contents)?;
|
||||||
|
Ok(stdin_contents)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_anonymous_parse<P: AsRef<str>>(org_contents: P) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let org_contents = org_contents.as_ref();
|
||||||
|
let rust_parsed = parse(org_contents)?;
|
||||||
|
println!("{:#?}", rust_parsed);
|
||||||
|
#[cfg(feature = "event_count")]
|
||||||
|
crate::event_count::report(org_contents);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let org_path = org_path.as_ref();
|
||||||
|
let parent_directory = org_path
|
||||||
|
.parent()
|
||||||
|
.ok_or("Should be contained inside a directory.")?;
|
||||||
|
let org_contents = std::fs::read_to_string(org_path)?;
|
||||||
|
let org_contents = org_contents.as_str();
|
||||||
|
let file_access_interface = LocalFileAccessInterface {
|
||||||
|
working_directory: Some(parent_directory.to_path_buf()),
|
||||||
|
};
|
||||||
|
let global_settings = GlobalSettings {
|
||||||
|
file_access: &file_access_interface,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let rust_parsed = parse_with_settings(org_contents, &global_settings)?;
|
||||||
|
println!("{:#?}", rust_parsed);
|
||||||
|
#[cfg(feature = "event_count")]
|
||||||
|
crate::event_count::report(org_contents);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -106,7 +106,6 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::context::bind_context;
|
use crate::context::bind_context;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::context::ContextElement;
|
|
||||||
use crate::context::GlobalSettings;
|
use crate::context::GlobalSettings;
|
||||||
use crate::context::List;
|
use crate::context::List;
|
||||||
|
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ fn _heading<'b, 'g, 'r, 's>(
|
|||||||
// If the section has a planning then the timestamp values are copied to the heading.
|
// If the section has a planning then the timestamp values are copied to the heading.
|
||||||
if let DocumentElement::Section(inner_section) = §ion {
|
if let DocumentElement::Section(inner_section) = §ion {
|
||||||
if let Some(Element::Planning(planning)) = inner_section.children.first() {
|
if let Some(Element::Planning(planning)) = inner_section.children.first() {
|
||||||
scheduled = planning.scheduled.clone();
|
scheduled.clone_from(&planning.scheduled);
|
||||||
deadline = planning.deadline.clone();
|
deadline.clone_from(&planning.deadline);
|
||||||
closed = planning.closed.clone();
|
closed.clone_from(&planning.closed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
children.insert(0, section);
|
children.insert(0, section);
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ mod tests {
|
|||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::parser::OrgSource;
|
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_affiliated_keyword(b: &mut Bencher) {
|
fn bench_affiliated_keyword(b: &mut Bencher) {
|
||||||
|
|||||||
@@ -175,9 +175,7 @@ pub(crate) trait RematchObject<'x> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::context::Context;
|
|
||||||
use crate::context::GlobalSettings;
|
use crate::context::GlobalSettings;
|
||||||
use crate::context::List;
|
|
||||||
use crate::parser::element_parser::element;
|
use crate::parser::element_parser::element;
|
||||||
use crate::types::Bold;
|
use crate::types::Bold;
|
||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ pub struct Section<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DocumentElement<'s> {
|
pub enum DocumentElement<'s> {
|
||||||
Heading(Heading<'s>),
|
Heading(Heading<'s>),
|
||||||
Section(Section<'s>),
|
Section(Section<'s>),
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ mod greater_element;
|
|||||||
mod lesser_element;
|
mod lesser_element;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod object;
|
mod object;
|
||||||
mod remove_trailing;
|
|
||||||
mod standard_properties;
|
mod standard_properties;
|
||||||
mod util;
|
mod util;
|
||||||
pub use affiliated_keyword::AffiliatedKeyword;
|
pub use affiliated_keyword::AffiliatedKeyword;
|
||||||
|
|||||||
@@ -332,19 +332,19 @@ pub type HourInner = u8;
|
|||||||
pub type MinuteInner = u8;
|
pub type MinuteInner = u8;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Year(YearInner);
|
pub struct Year(pub YearInner);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Month(MonthInner);
|
pub struct Month(pub MonthInner);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DayOfMonth(DayOfMonthInner);
|
pub struct DayOfMonth(pub DayOfMonthInner);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Hour(HourInner);
|
pub struct Hour(pub HourInner);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Minute(MinuteInner);
|
pub struct Minute(pub MinuteInner);
|
||||||
|
|
||||||
impl Year {
|
impl Year {
|
||||||
// TODO: Make a real error type instead of a boxed any error.
|
// TODO: Make a real error type instead of a boxed any error.
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
pub(crate) trait RemoveTrailing: Iterator + Sized {
|
|
||||||
fn remove_trailing<R: Into<usize>>(self, amount_to_remove: R) -> RemoveTrailingIter<Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I> RemoveTrailing for I
|
|
||||||
where
|
|
||||||
I: Iterator,
|
|
||||||
{
|
|
||||||
fn remove_trailing<R: Into<usize>>(self, amount_to_remove: R) -> RemoveTrailingIter<Self> {
|
|
||||||
RemoveTrailingIter {
|
|
||||||
inner: self,
|
|
||||||
buffer: Vec::new(),
|
|
||||||
next_to_pop: 0,
|
|
||||||
amount_to_remove: amount_to_remove.into(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct RemoveTrailingIter<I: Iterator> {
|
|
||||||
inner: I,
|
|
||||||
buffer: Vec<I::Item>,
|
|
||||||
next_to_pop: usize,
|
|
||||||
amount_to_remove: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I: Iterator> Iterator for RemoveTrailingIter<I> {
|
|
||||||
type Item = I::Item;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
if self.buffer.len() < self.amount_to_remove {
|
|
||||||
self.buffer.reserve_exact(self.amount_to_remove);
|
|
||||||
}
|
|
||||||
while self.buffer.len() < self.amount_to_remove {
|
|
||||||
if let Some(elem) = self.inner.next() {
|
|
||||||
self.buffer.push(elem);
|
|
||||||
} else {
|
|
||||||
// The inner was smaller than amount_to_remove, so never return anything.
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_value = self.inner.next();
|
|
||||||
if self.amount_to_remove == 0 {
|
|
||||||
return new_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(new_value) = new_value {
|
|
||||||
let ret = std::mem::replace(&mut self.buffer[self.next_to_pop], new_value);
|
|
||||||
self.next_to_pop = (self.next_to_pop + 1) % self.amount_to_remove;
|
|
||||||
Some(ret)
|
|
||||||
} else {
|
|
||||||
// We have exactly the amount in the buffer than we wanted to cut off, so stop returning values.
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
191
src/util/cli.rs
Normal file
191
src/util/cli.rs
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use tokio::process::Command;
|
||||||
|
|
||||||
|
use crate::settings::GlobalSettings;
|
||||||
|
use crate::settings::HeadlineLevelFilter;
|
||||||
|
|
||||||
|
pub async fn print_versions() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
eprintln!("Using emacs version: {}", get_emacs_version().await?.trim());
|
||||||
|
eprintln!(
|
||||||
|
"Using org-mode version: {}",
|
||||||
|
get_org_mode_version().await?.trim()
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
let elisp_script = r#"(progn
|
||||||
|
(message "%s" (version))
|
||||||
|
)"#;
|
||||||
|
let mut cmd = Command::new("emacs");
|
||||||
|
let cmd = cmd
|
||||||
|
.arg("-q")
|
||||||
|
.arg("--no-site-file")
|
||||||
|
.arg("--no-splash")
|
||||||
|
.arg("--batch")
|
||||||
|
.arg("--eval")
|
||||||
|
.arg(elisp_script);
|
||||||
|
|
||||||
|
let out = cmd.output().await?;
|
||||||
|
out.status.exit_ok()?;
|
||||||
|
Ok(String::from_utf8(out.stderr)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
let elisp_script = r#"(progn
|
||||||
|
(org-mode)
|
||||||
|
(message "%s" (org-version nil t nil))
|
||||||
|
)"#;
|
||||||
|
let mut cmd = Command::new("emacs");
|
||||||
|
let cmd = cmd
|
||||||
|
.arg("-q")
|
||||||
|
.arg("--no-site-file")
|
||||||
|
.arg("--no-splash")
|
||||||
|
.arg("--batch")
|
||||||
|
.arg("--eval")
|
||||||
|
.arg(elisp_script);
|
||||||
|
|
||||||
|
let out = cmd.output().await?;
|
||||||
|
out.status.exit_ok()?;
|
||||||
|
Ok(String::from_utf8(out.stderr)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn emacs_parse_anonymous_org_document<'g, 's, C>(
|
||||||
|
file_contents: C,
|
||||||
|
global_settings: &GlobalSettings<'g, 's>,
|
||||||
|
) -> Result<String, Box<dyn std::error::Error>>
|
||||||
|
where
|
||||||
|
C: AsRef<str>,
|
||||||
|
{
|
||||||
|
let escaped_file_contents = escape_elisp_string(file_contents);
|
||||||
|
let elisp_script = format!(
|
||||||
|
r#"(progn
|
||||||
|
(erase-buffer)
|
||||||
|
(require 'org)
|
||||||
|
(defun org-table-align () t)
|
||||||
|
(insert "{escaped_file_contents}")
|
||||||
|
{global_settings}
|
||||||
|
(org-mode)
|
||||||
|
(message "%s" (pp-to-string (org-element-parse-buffer)))
|
||||||
|
)"#,
|
||||||
|
escaped_file_contents = escaped_file_contents,
|
||||||
|
global_settings = global_settings_elisp(global_settings)
|
||||||
|
);
|
||||||
|
let mut cmd = Command::new("emacs");
|
||||||
|
let cmd = cmd
|
||||||
|
.arg("-q")
|
||||||
|
.arg("--no-site-file")
|
||||||
|
.arg("--no-splash")
|
||||||
|
.arg("--batch")
|
||||||
|
.arg("--eval")
|
||||||
|
.arg(elisp_script);
|
||||||
|
let out = cmd.output().await?;
|
||||||
|
let status = out.status.exit_ok();
|
||||||
|
if status.is_err() {
|
||||||
|
eprintln!(
|
||||||
|
"Emacs errored out: {}\n{}",
|
||||||
|
String::from_utf8(out.stdout)?,
|
||||||
|
String::from_utf8(out.stderr)?
|
||||||
|
);
|
||||||
|
status?;
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
let org_sexp = out.stderr;
|
||||||
|
Ok(String::from_utf8(org_sexp)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn emacs_parse_file_org_document<'g, 's, P>(
|
||||||
|
file_path: P,
|
||||||
|
global_settings: &GlobalSettings<'g, 's>,
|
||||||
|
) -> Result<String, Box<dyn std::error::Error>>
|
||||||
|
where
|
||||||
|
P: AsRef<Path>,
|
||||||
|
{
|
||||||
|
let file_path = file_path.as_ref().canonicalize()?;
|
||||||
|
let containing_directory = file_path.parent().ok_or(format!(
|
||||||
|
"Failed to get containing directory for path {}",
|
||||||
|
file_path.display()
|
||||||
|
))?;
|
||||||
|
let elisp_script = format!(
|
||||||
|
r#"(progn
|
||||||
|
(require 'org)
|
||||||
|
(defun org-table-align () t)
|
||||||
|
(setq vc-handled-backends nil)
|
||||||
|
{global_settings}
|
||||||
|
(find-file-read-only "{file_path}")
|
||||||
|
(org-mode)
|
||||||
|
(message "%s" (pp-to-string (org-element-parse-buffer)))
|
||||||
|
)"#,
|
||||||
|
global_settings = global_settings_elisp(global_settings),
|
||||||
|
file_path = file_path
|
||||||
|
.as_os_str()
|
||||||
|
.to_str()
|
||||||
|
.expect("File name should be valid utf-8.")
|
||||||
|
);
|
||||||
|
let mut cmd = Command::new("emacs");
|
||||||
|
let cmd = cmd
|
||||||
|
.current_dir(containing_directory)
|
||||||
|
.arg("-q")
|
||||||
|
.arg("--no-site-file")
|
||||||
|
.arg("--no-splash")
|
||||||
|
.arg("--batch")
|
||||||
|
.arg("--eval")
|
||||||
|
.arg(elisp_script);
|
||||||
|
let out = cmd.output().await?;
|
||||||
|
let status = out.status.exit_ok();
|
||||||
|
if status.is_err() {
|
||||||
|
eprintln!(
|
||||||
|
"Emacs errored out: {}\n{}",
|
||||||
|
String::from_utf8(out.stdout)?,
|
||||||
|
String::from_utf8(out.stderr)?
|
||||||
|
);
|
||||||
|
status?;
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
let org_sexp = out.stderr;
|
||||||
|
Ok(String::from_utf8(org_sexp)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn escape_elisp_string<C>(file_contents: C) -> String
|
||||||
|
where
|
||||||
|
C: AsRef<str>,
|
||||||
|
{
|
||||||
|
let source = file_contents.as_ref();
|
||||||
|
let source_len = source.len();
|
||||||
|
// We allocate a string 10% larger than the source to account for escape characters. Without this, we would have more allocations during processing.
|
||||||
|
let mut output = String::with_capacity(source_len + (source_len / 10));
|
||||||
|
for c in source.chars() {
|
||||||
|
match c {
|
||||||
|
'"' | '\\' => {
|
||||||
|
output.push('\\');
|
||||||
|
output.push(c);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
output.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generate elisp to configure org-mode parsing settings
|
||||||
|
///
|
||||||
|
/// Currently only org-list-allow-alphabetical is supported.
|
||||||
|
fn global_settings_elisp(global_settings: &GlobalSettings) -> String {
|
||||||
|
// This string concatenation is wildly inefficient but its only called in tests 🤷.
|
||||||
|
let mut ret = "".to_owned();
|
||||||
|
if global_settings.list_allow_alphabetical {
|
||||||
|
ret += "(setq org-list-allow-alphabetical t)\n"
|
||||||
|
}
|
||||||
|
if global_settings.tab_width != crate::settings::DEFAULT_TAB_WIDTH {
|
||||||
|
ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str();
|
||||||
|
}
|
||||||
|
if global_settings.odd_levels_only != HeadlineLevelFilter::default() {
|
||||||
|
ret += match global_settings.odd_levels_only {
|
||||||
|
HeadlineLevelFilter::Odd => "(setq org-odd-levels-only t)\n",
|
||||||
|
HeadlineLevelFilter::OddEven => "(setq org-odd-levels-only nil)\n",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
14
src/util/elisp/mod.rs
Normal file
14
src/util/elisp/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
mod sexp;
|
||||||
|
mod util;
|
||||||
|
|
||||||
|
pub use sexp::sexp;
|
||||||
|
pub(crate) use sexp::unquote;
|
||||||
|
#[cfg(feature = "wasm_test")]
|
||||||
|
pub(crate) use sexp::TextWithProperties;
|
||||||
|
pub use sexp::Token;
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
|
pub(crate) use util::get_emacs_standard_properties;
|
||||||
|
#[cfg(feature = "wasm_test")]
|
||||||
|
pub(crate) use util::maybe_token_to_usize;
|
||||||
|
#[cfg(feature = "wasm_test")]
|
||||||
|
pub(crate) use util::EmacsStandardProperties;
|
||||||
@@ -61,6 +61,7 @@ impl<'s> Token<'s> {
|
|||||||
}?)
|
}?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
pub(crate) fn as_text<'p>(
|
pub(crate) fn as_text<'p>(
|
||||||
&'p self,
|
&'p self,
|
||||||
) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
|
) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
|
||||||
76
src/util/elisp/util.rs
Normal file
76
src/util/elisp/util.rs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
use super::Token;
|
||||||
|
|
||||||
|
pub(crate) fn maybe_token_to_usize(
|
||||||
|
token: Option<&Token<'_>>,
|
||||||
|
) -> Result<Option<usize>, Box<dyn std::error::Error>> {
|
||||||
|
Ok(token
|
||||||
|
.map(|token| token.as_atom())
|
||||||
|
.map_or(Ok(None), |r| r.map(Some))?
|
||||||
|
.and_then(|val| {
|
||||||
|
if val == "nil" {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(val.parse::<usize>())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map_or(Ok(None), |r| r.map(Some))?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct EmacsStandardProperties {
|
||||||
|
pub(crate) begin: Option<usize>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) post_affiliated: Option<usize>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) contents_begin: Option<usize>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) contents_end: Option<usize>,
|
||||||
|
pub(crate) end: Option<usize>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) post_blank: Option<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
|
pub(crate) fn get_emacs_standard_properties(
|
||||||
|
emacs: &Token<'_>,
|
||||||
|
) -> Result<EmacsStandardProperties, Box<dyn std::error::Error>> {
|
||||||
|
let children = emacs.as_list()?;
|
||||||
|
let attributes_child = children.get(1).ok_or("Should have an attributes child.")?;
|
||||||
|
let attributes_map = attributes_child.as_map()?;
|
||||||
|
let standard_properties = attributes_map.get(":standard-properties");
|
||||||
|
Ok(if standard_properties.is_some() {
|
||||||
|
let mut std_props = standard_properties
|
||||||
|
.expect("if statement proves its Some")
|
||||||
|
.as_vector()?
|
||||||
|
.iter();
|
||||||
|
let begin = maybe_token_to_usize(std_props.next())?;
|
||||||
|
let post_affiliated = maybe_token_to_usize(std_props.next())?;
|
||||||
|
let contents_begin = maybe_token_to_usize(std_props.next())?;
|
||||||
|
let contents_end = maybe_token_to_usize(std_props.next())?;
|
||||||
|
let end = maybe_token_to_usize(std_props.next())?;
|
||||||
|
let post_blank = maybe_token_to_usize(std_props.next())?;
|
||||||
|
EmacsStandardProperties {
|
||||||
|
begin,
|
||||||
|
post_affiliated,
|
||||||
|
contents_begin,
|
||||||
|
contents_end,
|
||||||
|
end,
|
||||||
|
post_blank,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let begin = maybe_token_to_usize(attributes_map.get(":begin").copied())?;
|
||||||
|
let end = maybe_token_to_usize(attributes_map.get(":end").copied())?;
|
||||||
|
let contents_begin = maybe_token_to_usize(attributes_map.get(":contents-begin").copied())?;
|
||||||
|
let contents_end = maybe_token_to_usize(attributes_map.get(":contents-end").copied())?;
|
||||||
|
let post_blank = maybe_token_to_usize(attributes_map.get(":post-blank").copied())?;
|
||||||
|
let post_affiliated =
|
||||||
|
maybe_token_to_usize(attributes_map.get(":post-affiliated").copied())?;
|
||||||
|
EmacsStandardProperties {
|
||||||
|
begin,
|
||||||
|
post_affiliated,
|
||||||
|
contents_begin,
|
||||||
|
contents_end,
|
||||||
|
end,
|
||||||
|
post_blank,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
241
src/util/mod.rs
241
src/util/mod.rs
@@ -1,233 +1,8 @@
|
|||||||
use std::borrow::Cow;
|
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
||||||
use std::path::Path;
|
pub mod cli;
|
||||||
|
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
||||||
use tokio::process::Command;
|
pub mod elisp;
|
||||||
|
#[cfg(any(feature = "compare", feature = "wasm", feature = "wasm_test"))]
|
||||||
use crate::settings::GlobalSettings;
|
pub mod elisp_fact;
|
||||||
use crate::settings::HeadlineLevelFilter;
|
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
||||||
|
pub mod terminal;
|
||||||
pub async fn print_versions() -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
eprintln!("Using emacs version: {}", get_emacs_version().await?.trim());
|
|
||||||
eprintln!(
|
|
||||||
"Using org-mode version: {}",
|
|
||||||
get_org_mode_version().await?.trim()
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
|
|
||||||
let elisp_script = r#"(progn
|
|
||||||
(message "%s" (version))
|
|
||||||
)"#;
|
|
||||||
let mut cmd = Command::new("emacs");
|
|
||||||
let cmd = cmd
|
|
||||||
.arg("-q")
|
|
||||||
.arg("--no-site-file")
|
|
||||||
.arg("--no-splash")
|
|
||||||
.arg("--batch")
|
|
||||||
.arg("--eval")
|
|
||||||
.arg(elisp_script);
|
|
||||||
|
|
||||||
let out = cmd.output().await?;
|
|
||||||
out.status.exit_ok()?;
|
|
||||||
Ok(String::from_utf8(out.stderr)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
|
|
||||||
let elisp_script = r#"(progn
|
|
||||||
(org-mode)
|
|
||||||
(message "%s" (org-version nil t nil))
|
|
||||||
)"#;
|
|
||||||
let mut cmd = Command::new("emacs");
|
|
||||||
let cmd = cmd
|
|
||||||
.arg("-q")
|
|
||||||
.arg("--no-site-file")
|
|
||||||
.arg("--no-splash")
|
|
||||||
.arg("--batch")
|
|
||||||
.arg("--eval")
|
|
||||||
.arg(elisp_script);
|
|
||||||
|
|
||||||
let out = cmd.output().await?;
|
|
||||||
out.status.exit_ok()?;
|
|
||||||
Ok(String::from_utf8(out.stderr)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn emacs_parse_anonymous_org_document<'g, 's, C>(
|
|
||||||
file_contents: C,
|
|
||||||
global_settings: &GlobalSettings<'g, 's>,
|
|
||||||
) -> Result<String, Box<dyn std::error::Error>>
|
|
||||||
where
|
|
||||||
C: AsRef<str>,
|
|
||||||
{
|
|
||||||
let escaped_file_contents = escape_elisp_string(file_contents);
|
|
||||||
let elisp_script = format!(
|
|
||||||
r#"(progn
|
|
||||||
(erase-buffer)
|
|
||||||
(require 'org)
|
|
||||||
(defun org-table-align () t)
|
|
||||||
(insert "{escaped_file_contents}")
|
|
||||||
{global_settings}
|
|
||||||
(org-mode)
|
|
||||||
(message "%s" (pp-to-string (org-element-parse-buffer)))
|
|
||||||
)"#,
|
|
||||||
escaped_file_contents = escaped_file_contents,
|
|
||||||
global_settings = global_settings_elisp(global_settings)
|
|
||||||
);
|
|
||||||
let mut cmd = Command::new("emacs");
|
|
||||||
let cmd = cmd
|
|
||||||
.arg("-q")
|
|
||||||
.arg("--no-site-file")
|
|
||||||
.arg("--no-splash")
|
|
||||||
.arg("--batch")
|
|
||||||
.arg("--eval")
|
|
||||||
.arg(elisp_script);
|
|
||||||
let out = cmd.output().await?;
|
|
||||||
let status = out.status.exit_ok();
|
|
||||||
if status.is_err() {
|
|
||||||
eprintln!(
|
|
||||||
"Emacs errored out: {}\n{}",
|
|
||||||
String::from_utf8(out.stdout)?,
|
|
||||||
String::from_utf8(out.stderr)?
|
|
||||||
);
|
|
||||||
status?;
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
let org_sexp = out.stderr;
|
|
||||||
Ok(String::from_utf8(org_sexp)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) async fn emacs_parse_file_org_document<'g, 's, P>(
|
|
||||||
file_path: P,
|
|
||||||
global_settings: &GlobalSettings<'g, 's>,
|
|
||||||
) -> Result<String, Box<dyn std::error::Error>>
|
|
||||||
where
|
|
||||||
P: AsRef<Path>,
|
|
||||||
{
|
|
||||||
let file_path = file_path.as_ref().canonicalize()?;
|
|
||||||
let containing_directory = file_path.parent().ok_or(format!(
|
|
||||||
"Failed to get containing directory for path {}",
|
|
||||||
file_path.display()
|
|
||||||
))?;
|
|
||||||
let elisp_script = format!(
|
|
||||||
r#"(progn
|
|
||||||
(require 'org)
|
|
||||||
(defun org-table-align () t)
|
|
||||||
(setq vc-handled-backends nil)
|
|
||||||
{global_settings}
|
|
||||||
(find-file-read-only "{file_path}")
|
|
||||||
(org-mode)
|
|
||||||
(message "%s" (pp-to-string (org-element-parse-buffer)))
|
|
||||||
)"#,
|
|
||||||
global_settings = global_settings_elisp(global_settings),
|
|
||||||
file_path = file_path
|
|
||||||
.as_os_str()
|
|
||||||
.to_str()
|
|
||||||
.expect("File name should be valid utf-8.")
|
|
||||||
);
|
|
||||||
let mut cmd = Command::new("emacs");
|
|
||||||
let cmd = cmd
|
|
||||||
.current_dir(containing_directory)
|
|
||||||
.arg("-q")
|
|
||||||
.arg("--no-site-file")
|
|
||||||
.arg("--no-splash")
|
|
||||||
.arg("--batch")
|
|
||||||
.arg("--eval")
|
|
||||||
.arg(elisp_script);
|
|
||||||
let out = cmd.output().await?;
|
|
||||||
let status = out.status.exit_ok();
|
|
||||||
if status.is_err() {
|
|
||||||
eprintln!(
|
|
||||||
"Emacs errored out: {}\n{}",
|
|
||||||
String::from_utf8(out.stdout)?,
|
|
||||||
String::from_utf8(out.stderr)?
|
|
||||||
);
|
|
||||||
status?;
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
let org_sexp = out.stderr;
|
|
||||||
Ok(String::from_utf8(org_sexp)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn escape_elisp_string<C>(file_contents: C) -> String
|
|
||||||
where
|
|
||||||
C: AsRef<str>,
|
|
||||||
{
|
|
||||||
let source = file_contents.as_ref();
|
|
||||||
let source_len = source.len();
|
|
||||||
// We allocate a string 10% larger than the source to account for escape characters. Without this, we would have more allocations during processing.
|
|
||||||
let mut output = String::with_capacity(source_len + (source_len / 10));
|
|
||||||
for c in source.chars() {
|
|
||||||
match c {
|
|
||||||
'"' | '\\' => {
|
|
||||||
output.push('\\');
|
|
||||||
output.push(c);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
output.push(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate elisp to configure org-mode parsing settings
|
|
||||||
///
|
|
||||||
/// Currently only org-list-allow-alphabetical is supported.
|
|
||||||
fn global_settings_elisp(global_settings: &GlobalSettings) -> String {
|
|
||||||
// This string concatenation is wildly inefficient but its only called in tests 🤷.
|
|
||||||
let mut ret = "".to_owned();
|
|
||||||
if global_settings.list_allow_alphabetical {
|
|
||||||
ret += "(setq org-list-allow-alphabetical t)\n"
|
|
||||||
}
|
|
||||||
if global_settings.tab_width != crate::settings::DEFAULT_TAB_WIDTH {
|
|
||||||
ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str();
|
|
||||||
}
|
|
||||||
if global_settings.odd_levels_only != HeadlineLevelFilter::default() {
|
|
||||||
ret += match global_settings.odd_levels_only {
|
|
||||||
HeadlineLevelFilter::Odd => "(setq org-odd-levels-only t)\n",
|
|
||||||
HeadlineLevelFilter::OddEven => "(setq org-odd-levels-only nil)\n",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
|
|
||||||
fn should_use_color() -> bool {
|
|
||||||
!std::env::var("NO_COLOR").is_ok_and(|val| !val.is_empty())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn foreground_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
|
|
||||||
if should_use_color() {
|
|
||||||
format!(
|
|
||||||
"\x1b[38;2;{red};{green};{blue}m",
|
|
||||||
red = red,
|
|
||||||
green = green,
|
|
||||||
blue = blue
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
} else {
|
|
||||||
Cow::from("")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn background_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
|
|
||||||
if should_use_color() {
|
|
||||||
format!(
|
|
||||||
"\x1b[48;2;{red};{green};{blue}m",
|
|
||||||
red = red,
|
|
||||||
green = green,
|
|
||||||
blue = blue
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
} else {
|
|
||||||
Cow::from("")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn reset_color() -> &'static str {
|
|
||||||
if should_use_color() {
|
|
||||||
"\x1b[0m"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
42
src/util/terminal.rs
Normal file
42
src/util/terminal.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
fn should_use_color() -> bool {
|
||||||
|
!std::env::var("NO_COLOR").is_ok_and(|val| !val.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn foreground_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
|
||||||
|
if should_use_color() {
|
||||||
|
format!(
|
||||||
|
"\x1b[38;2;{red};{green};{blue}m",
|
||||||
|
red = red,
|
||||||
|
green = green,
|
||||||
|
blue = blue
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
} else {
|
||||||
|
Cow::from("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) fn background_color(red: u8, green: u8, blue: u8) -> Cow<'static, str> {
|
||||||
|
if should_use_color() {
|
||||||
|
format!(
|
||||||
|
"\x1b[48;2;{red};{green};{blue}m",
|
||||||
|
red = red,
|
||||||
|
green = green,
|
||||||
|
blue = blue
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
} else {
|
||||||
|
Cow::from("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn reset_color() -> &'static str {
|
||||||
|
if should_use_color() {
|
||||||
|
"\x1b[0m"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
95
src/wasm/additional_property.rs
Normal file
95
src/wasm/additional_property.rs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::WasmAstNode;
|
||||||
|
use crate::types::AffiliatedKeywordValue;
|
||||||
|
use crate::types::AffiliatedKeywords;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum AdditionalPropertyValue {
|
||||||
|
SingleString(String),
|
||||||
|
ListOfStrings(Vec<String>),
|
||||||
|
OptionalPair {
|
||||||
|
optval: Option<String>,
|
||||||
|
val: String,
|
||||||
|
},
|
||||||
|
ObjectTree {
|
||||||
|
#[serde(rename = "object-tree")]
|
||||||
|
object_tree: Vec<(Option<Vec<WasmAstNode>>, Vec<WasmAstNode>)>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||||
|
pub struct AdditionalProperties {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub(crate) properties: HashMap<String, AdditionalPropertyValue>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
AdditionalProperties,
|
||||||
|
AffiliatedKeywords<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
{
|
||||||
|
let mut additional_properties = AdditionalProperties::default();
|
||||||
|
for (name, val) in original.keywords.iter() {
|
||||||
|
let converted_val = match val {
|
||||||
|
AffiliatedKeywordValue::SingleString(val) => {
|
||||||
|
AdditionalPropertyValue::SingleString((*val).to_owned())
|
||||||
|
}
|
||||||
|
AffiliatedKeywordValue::ListOfStrings(val) => {
|
||||||
|
AdditionalPropertyValue::ListOfStrings(
|
||||||
|
val.iter().map(|s| (*s).to_owned()).collect(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
AffiliatedKeywordValue::OptionalPair { optval, val } => {
|
||||||
|
AdditionalPropertyValue::OptionalPair {
|
||||||
|
optval: optval.map(|s| (*s).to_owned()),
|
||||||
|
val: (*val).to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AffiliatedKeywordValue::ObjectTree(val) => {
|
||||||
|
let mut ret = Vec::with_capacity(val.len());
|
||||||
|
|
||||||
|
for (optval, value) in val {
|
||||||
|
let converted_optval = if let Some(optval) = optval {
|
||||||
|
Some(
|
||||||
|
optval
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let converted_value = value
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
ret.push((converted_optval, converted_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
AdditionalPropertyValue::ObjectTree { object_tree: ret }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
additional_properties
|
||||||
|
.properties
|
||||||
|
.insert(name.clone(), converted_val);
|
||||||
|
}
|
||||||
|
Ok(additional_properties)
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -1,30 +1,54 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::AngleLink;
|
use crate::types::AngleLink;
|
||||||
|
use crate::types::LinkType;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
#[serde(tag = "format")]
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "angle")]
|
||||||
pub struct WasmAngleLink<'s, 'p> {
|
pub struct WasmAngleLink {
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "type")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) link_type: String,
|
||||||
|
pub(crate) path: String,
|
||||||
|
#[serde(rename = "raw-link")]
|
||||||
|
pub(crate) raw_link: String,
|
||||||
|
pub(crate) application: Option<String>,
|
||||||
|
#[serde(rename = "search-option")]
|
||||||
|
pub(crate) search_option: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmAngleLink<'s, 'p>,
|
WasmAngleLink,
|
||||||
AngleLink<'s>,
|
AngleLink<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::AngleLink(original) },
|
||||||
|
{ "link".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmAngleLink {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmAngleLink {
|
||||||
})
|
link_type: match &original.link_type {
|
||||||
|
LinkType::File => "file".to_owned(),
|
||||||
|
LinkType::Protocol(protocol) => protocol.clone().into_owned(),
|
||||||
|
LinkType::Id => "id".to_owned(),
|
||||||
|
LinkType::CustomId => "custom-id".to_owned(),
|
||||||
|
LinkType::CodeRef => "coderef".to_owned(),
|
||||||
|
LinkType::Fuzzy => "fuzzy".to_owned(),
|
||||||
|
},
|
||||||
|
path: original.get_path().into_owned(),
|
||||||
|
raw_link: original.raw_link.to_owned(),
|
||||||
|
application: original.application.map(|c| c.to_owned()),
|
||||||
|
search_option: original.get_search_option().map(Cow::into_owned),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::angle_link::WasmAngleLink;
|
use super::angle_link::WasmAngleLink;
|
||||||
@@ -58,71 +59,84 @@ use super::timestamp::WasmTimestamp;
|
|||||||
use super::underline::WasmUnderline;
|
use super::underline::WasmUnderline;
|
||||||
use super::verbatim::WasmVerbatim;
|
use super::verbatim::WasmVerbatim;
|
||||||
use super::verse_block::WasmVerseBlock;
|
use super::verse_block::WasmVerseBlock;
|
||||||
|
use super::WasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
pub struct WasmAstNodeWrapper<I> {
|
||||||
pub enum WasmAstNode<'s, 'p> {
|
#[serde(rename = "ast-node")]
|
||||||
// Document Nodes
|
pub(crate) ast_node: String,
|
||||||
Document(WasmDocument<'s, 'p>),
|
#[serde(rename = "standard-properties")]
|
||||||
Headline(WasmHeadline<'s, 'p>),
|
pub(crate) standard_properties: WasmStandardProperties,
|
||||||
Section(WasmSection<'s, 'p>),
|
#[serde(rename = "children")]
|
||||||
// Elements
|
pub(crate) children: Vec<WasmAstNode>,
|
||||||
Paragraph(WasmParagraph<'s, 'p>),
|
#[serde(rename = "properties")]
|
||||||
PlainList(WasmPlainList<'s, 'p>),
|
pub(crate) properties: I,
|
||||||
PlainListItem(WasmPlainListItem<'s, 'p>),
|
|
||||||
CenterBlock(WasmCenterBlock<'s, 'p>),
|
|
||||||
QuoteBlock(WasmQuoteBlock<'s, 'p>),
|
|
||||||
SpecialBlock(WasmSpecialBlock<'s, 'p>),
|
|
||||||
DynamicBlock(WasmDynamicBlock<'s, 'p>),
|
|
||||||
FootnoteDefinition(WasmFootnoteDefinition<'s, 'p>),
|
|
||||||
Comment(WasmComment<'s, 'p>),
|
|
||||||
Drawer(WasmDrawer<'s, 'p>),
|
|
||||||
PropertyDrawer(WasmPropertyDrawer<'s, 'p>),
|
|
||||||
NodeProperty(WasmNodeProperty<'s, 'p>),
|
|
||||||
Table(WasmTable<'s, 'p>),
|
|
||||||
TableRow(WasmTableRow<'s, 'p>),
|
|
||||||
VerseBlock(WasmVerseBlock<'s, 'p>),
|
|
||||||
CommentBlock(WasmCommentBlock<'s, 'p>),
|
|
||||||
ExampleBlock(WasmExampleBlock<'s, 'p>),
|
|
||||||
ExportBlock(WasmExportBlock<'s, 'p>),
|
|
||||||
SrcBlock(WasmSrcBlock<'s, 'p>),
|
|
||||||
Clock(WasmClock<'s, 'p>),
|
|
||||||
DiarySexp(WasmDiarySexp<'s, 'p>),
|
|
||||||
Planning(WasmPlanning<'s, 'p>),
|
|
||||||
FixedWidthArea(WasmFixedWidthArea<'s, 'p>),
|
|
||||||
HorizontalRule(WasmHorizontalRule<'s, 'p>),
|
|
||||||
Keyword(WasmKeyword<'s, 'p>),
|
|
||||||
BabelCall(WasmBabelCall<'s, 'p>),
|
|
||||||
LatexEnvironment(WasmLatexEnvironment<'s, 'p>),
|
|
||||||
// Objects
|
|
||||||
Bold(WasmBold<'s, 'p>),
|
|
||||||
Italic(WasmItalic<'s, 'p>),
|
|
||||||
Underline(WasmUnderline<'s, 'p>),
|
|
||||||
StrikeThrough(WasmStrikeThrough<'s, 'p>),
|
|
||||||
Code(WasmCode<'s, 'p>),
|
|
||||||
Verbatim(WasmVerbatim<'s, 'p>),
|
|
||||||
PlainText(WasmPlainText<'s, 'p>),
|
|
||||||
RegularLink(WasmRegularLink<'s, 'p>),
|
|
||||||
RadioLink(WasmRadioLink<'s, 'p>),
|
|
||||||
RadioTarget(WasmRadioTarget<'s, 'p>),
|
|
||||||
PlainLink(WasmPlainLink<'s, 'p>),
|
|
||||||
AngleLink(WasmAngleLink<'s, 'p>),
|
|
||||||
OrgMacro(WasmOrgMacro<'s, 'p>),
|
|
||||||
Entity(WasmEntity<'s, 'p>),
|
|
||||||
LatexFragment(WasmLatexFragment<'s, 'p>),
|
|
||||||
ExportSnippet(WasmExportSnippet<'s, 'p>),
|
|
||||||
FootnoteReference(WasmFootnoteReference<'s, 'p>),
|
|
||||||
Citation(WasmCitation<'s, 'p>),
|
|
||||||
CitationReference(WasmCitationReference<'s, 'p>),
|
|
||||||
InlineBabelCall(WasmInlineBabelCall<'s, 'p>),
|
|
||||||
InlineSourceBlock(WasmInlineSourceBlock<'s, 'p>),
|
|
||||||
LineBreak(WasmLineBreak<'s, 'p>),
|
|
||||||
Target(WasmTarget<'s, 'p>),
|
|
||||||
StatisticsCookie(WasmStatisticsCookie<'s, 'p>),
|
|
||||||
Subscript(WasmSubscript<'s, 'p>),
|
|
||||||
Superscript(WasmSuperscript<'s, 'p>),
|
|
||||||
TableCell(WasmTableCell<'s, 'p>),
|
|
||||||
Timestamp(WasmTimestamp<'s, 'p>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s, 'p> WasmAstNode<'s, 'p> {}
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum WasmAstNode {
|
||||||
|
// Document Nodes
|
||||||
|
Document(WasmAstNodeWrapper<WasmDocument>),
|
||||||
|
Headline(WasmAstNodeWrapper<WasmHeadline>),
|
||||||
|
Section(WasmAstNodeWrapper<WasmSection>),
|
||||||
|
// Elements
|
||||||
|
Paragraph(WasmAstNodeWrapper<WasmParagraph>),
|
||||||
|
PlainList(WasmAstNodeWrapper<WasmPlainList>),
|
||||||
|
PlainListItem(WasmAstNodeWrapper<WasmPlainListItem>),
|
||||||
|
CenterBlock(WasmAstNodeWrapper<WasmCenterBlock>),
|
||||||
|
QuoteBlock(WasmAstNodeWrapper<WasmQuoteBlock>),
|
||||||
|
SpecialBlock(WasmAstNodeWrapper<WasmSpecialBlock>),
|
||||||
|
DynamicBlock(WasmAstNodeWrapper<WasmDynamicBlock>),
|
||||||
|
FootnoteDefinition(WasmAstNodeWrapper<WasmFootnoteDefinition>),
|
||||||
|
Comment(WasmAstNodeWrapper<WasmComment>),
|
||||||
|
Drawer(WasmAstNodeWrapper<WasmDrawer>),
|
||||||
|
PropertyDrawer(WasmAstNodeWrapper<WasmPropertyDrawer>),
|
||||||
|
NodeProperty(WasmAstNodeWrapper<WasmNodeProperty>),
|
||||||
|
Table(WasmAstNodeWrapper<WasmTable>),
|
||||||
|
TableRow(WasmAstNodeWrapper<WasmTableRow>),
|
||||||
|
VerseBlock(WasmAstNodeWrapper<WasmVerseBlock>),
|
||||||
|
CommentBlock(WasmAstNodeWrapper<WasmCommentBlock>),
|
||||||
|
ExampleBlock(WasmAstNodeWrapper<WasmExampleBlock>),
|
||||||
|
ExportBlock(WasmAstNodeWrapper<WasmExportBlock>),
|
||||||
|
SrcBlock(WasmAstNodeWrapper<WasmSrcBlock>),
|
||||||
|
Clock(WasmAstNodeWrapper<WasmClock>),
|
||||||
|
DiarySexp(WasmAstNodeWrapper<WasmDiarySexp>),
|
||||||
|
Planning(WasmAstNodeWrapper<WasmPlanning>),
|
||||||
|
FixedWidthArea(WasmAstNodeWrapper<WasmFixedWidthArea>),
|
||||||
|
HorizontalRule(WasmAstNodeWrapper<WasmHorizontalRule>),
|
||||||
|
Keyword(WasmAstNodeWrapper<WasmKeyword>),
|
||||||
|
BabelCall(WasmAstNodeWrapper<WasmBabelCall>),
|
||||||
|
LatexEnvironment(WasmAstNodeWrapper<WasmLatexEnvironment>),
|
||||||
|
// Objects
|
||||||
|
Bold(WasmAstNodeWrapper<WasmBold>),
|
||||||
|
Italic(WasmAstNodeWrapper<WasmItalic>),
|
||||||
|
Underline(WasmAstNodeWrapper<WasmUnderline>),
|
||||||
|
StrikeThrough(WasmAstNodeWrapper<WasmStrikeThrough>),
|
||||||
|
Code(WasmAstNodeWrapper<WasmCode>),
|
||||||
|
Verbatim(WasmAstNodeWrapper<WasmVerbatim>),
|
||||||
|
PlainText(WasmAstNodeWrapper<WasmPlainText>),
|
||||||
|
RegularLink(WasmAstNodeWrapper<WasmRegularLink>),
|
||||||
|
RadioLink(WasmAstNodeWrapper<WasmRadioLink>),
|
||||||
|
RadioTarget(WasmAstNodeWrapper<WasmRadioTarget>),
|
||||||
|
PlainLink(WasmAstNodeWrapper<WasmPlainLink>),
|
||||||
|
AngleLink(WasmAstNodeWrapper<WasmAngleLink>),
|
||||||
|
OrgMacro(WasmAstNodeWrapper<WasmOrgMacro>),
|
||||||
|
Entity(WasmAstNodeWrapper<WasmEntity>),
|
||||||
|
LatexFragment(WasmAstNodeWrapper<WasmLatexFragment>),
|
||||||
|
ExportSnippet(WasmAstNodeWrapper<WasmExportSnippet>),
|
||||||
|
FootnoteReference(WasmAstNodeWrapper<WasmFootnoteReference>),
|
||||||
|
Citation(WasmAstNodeWrapper<WasmCitation>),
|
||||||
|
CitationReference(WasmAstNodeWrapper<WasmCitationReference>),
|
||||||
|
InlineBabelCall(WasmAstNodeWrapper<WasmInlineBabelCall>),
|
||||||
|
InlineSourceBlock(WasmAstNodeWrapper<WasmInlineSourceBlock>),
|
||||||
|
LineBreak(WasmAstNodeWrapper<WasmLineBreak>),
|
||||||
|
Target(WasmAstNodeWrapper<WasmTarget>),
|
||||||
|
StatisticsCookie(WasmAstNodeWrapper<WasmStatisticsCookie>),
|
||||||
|
Subscript(WasmAstNodeWrapper<WasmSubscript>),
|
||||||
|
Superscript(WasmAstNodeWrapper<WasmSuperscript>),
|
||||||
|
TableCell(WasmAstNodeWrapper<WasmTableCell>),
|
||||||
|
Timestamp(WasmAstNodeWrapper<WasmTimestamp>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WasmAstNode {}
|
||||||
|
|||||||
@@ -1,30 +1,50 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::BabelCall;
|
use crate::types::BabelCall;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmBabelCall {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmBabelCall<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) call: Option<String>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
#[serde(rename = "inside-header")]
|
||||||
|
pub(crate) inside_header: Option<String>,
|
||||||
|
pub(crate) arguments: Option<String>,
|
||||||
|
#[serde(rename = "end-header")]
|
||||||
|
pub(crate) end_header: Option<String>,
|
||||||
|
pub(crate) value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmBabelCall<'s, 'p>,
|
WasmBabelCall,
|
||||||
BabelCall<'s>,
|
BabelCall<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::BabelCall(original) },
|
||||||
|
{ "babel-call".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmBabelCall {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmBabelCall {
|
||||||
|
additional_properties,
|
||||||
|
call: original.call.map(|s| s.to_owned()),
|
||||||
|
inside_header: original.inside_header.map(|s| s.to_owned()),
|
||||||
|
arguments: original.arguments.map(|s| s.to_owned()),
|
||||||
|
end_header: original.end_header.map(|s| s.to_owned()),
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,34 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Bold;
|
use crate::types::Bold;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmBold {}
|
||||||
#[serde(rename = "org-data")]
|
|
||||||
pub struct WasmBold<'s, 'p> {
|
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmBold<'s, 'p>,
|
WasmBold,
|
||||||
Bold<'s>,
|
Bold<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Bold(original) },
|
||||||
|
{ "bold".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmBold {
|
let children = original
|
||||||
standard_properties,
|
.children
|
||||||
children: Vec::new(),
|
.iter()
|
||||||
})
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((children, WasmBold {}))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,48 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::CenterBlock;
|
use crate::types::CenterBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmCenterBlock {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmCenterBlock<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmCenterBlock<'s, 'p>,
|
WasmCenterBlock,
|
||||||
CenterBlock<'s>,
|
CenterBlock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::CenterBlock(original) },
|
||||||
|
{ "center-block".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmCenterBlock {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmCenterBlock {
|
||||||
|
additional_properties,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,71 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Citation;
|
use crate::types::Citation;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmCitation {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) style: Option<String>,
|
||||||
pub struct WasmCitation<'s, 'p> {
|
pub(crate) prefix: Option<Vec<WasmAstNode>>,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) suffix: Option<Vec<WasmAstNode>>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmCitation<'s, 'p>,
|
WasmCitation,
|
||||||
Citation<'s>,
|
Citation<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Citation(original) },
|
||||||
|
{ "citation".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmCitation {
|
let children = original
|
||||||
standard_properties,
|
.children
|
||||||
children: Vec::new(),
|
.iter()
|
||||||
})
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let prefix = original
|
||||||
|
.prefix
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let suffix = original
|
||||||
|
.suffix
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmCitation {
|
||||||
|
style: original.style.map(|s| s.to_owned()),
|
||||||
|
prefix: if prefix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(prefix)
|
||||||
|
},
|
||||||
|
suffix: if suffix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(suffix)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,62 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::CitationReference;
|
use crate::types::CitationReference;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmCitationReference {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) key: String,
|
||||||
pub struct WasmCitationReference<'s, 'p> {
|
pub(crate) prefix: Option<Vec<WasmAstNode>>,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) suffix: Option<Vec<WasmAstNode>>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmCitationReference<'s, 'p>,
|
WasmCitationReference,
|
||||||
CitationReference<'s>,
|
CitationReference<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::CitationReference(original) },
|
||||||
|
{ "citation-reference".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmCitationReference {
|
let prefix = original
|
||||||
standard_properties,
|
.prefix
|
||||||
children: Vec::new(),
|
.iter()
|
||||||
})
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let suffix = original
|
||||||
|
.suffix
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmCitationReference {
|
||||||
|
key: original.key.to_owned(),
|
||||||
|
prefix: if prefix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(prefix)
|
||||||
|
},
|
||||||
|
suffix: if suffix.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(suffix)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,43 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Clock;
|
use crate::types::Clock;
|
||||||
|
use crate::types::ClockStatus;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmClock {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "value")]
|
||||||
pub struct WasmClock<'s, 'p> {
|
pub(crate) timestamp: Box<WasmAstNode>,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) duration: Option<String>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) status: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmClock<'s, 'p>,
|
WasmClock,
|
||||||
Clock<'s>,
|
Clock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Clock(original) },
|
||||||
|
{ "clock".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmClock {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmClock {
|
||||||
})
|
timestamp: Box::new(Into::<WasmAstNode>::into(
|
||||||
|
original.timestamp.to_wasm(wasm_context.clone())?,
|
||||||
|
)),
|
||||||
|
duration: original.duration.map(|s| s.to_owned()),
|
||||||
|
status: match original.status {
|
||||||
|
ClockStatus::Running => "running",
|
||||||
|
ClockStatus::Closed => "closed",
|
||||||
|
}
|
||||||
|
.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Code;
|
use crate::types::Code;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmCode {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) value: String,
|
||||||
pub struct WasmCode<'s, 'p> {
|
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmCode<'s, 'p>,
|
WasmCode,
|
||||||
Code<'s>,
|
Code<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Code(original) },
|
||||||
|
{ "code".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmCode {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmCode {
|
||||||
})
|
value: original.contents.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Comment;
|
use crate::types::Comment;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmComment {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) value: String,
|
||||||
pub struct WasmComment<'s, 'p> {
|
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmComment<'s, 'p>,
|
WasmComment,
|
||||||
Comment<'s>,
|
Comment<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Comment(original) },
|
||||||
|
{ "comment".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmComment {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmComment {
|
||||||
})
|
value: original.get_value(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,40 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::CommentBlock;
|
use crate::types::CommentBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmCommentBlock {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmCommentBlock<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) value: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmCommentBlock<'s, 'p>,
|
WasmCommentBlock,
|
||||||
CommentBlock<'s>,
|
CommentBlock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::CommentBlock(original) },
|
||||||
|
{ "comment-block".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmCommentBlock {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmCommentBlock {
|
||||||
|
additional_properties,
|
||||||
|
value: original.contents.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,40 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::DiarySexp;
|
use crate::types::DiarySexp;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmDiarySexp {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmDiarySexp<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) value: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmDiarySexp<'s, 'p>,
|
WasmDiarySexp,
|
||||||
DiarySexp<'s>,
|
DiarySexp<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::DiarySexp(original) },
|
||||||
|
{ "diary-sexp".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmDiarySexp {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmDiarySexp {
|
||||||
|
additional_properties,
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::additional_property::AdditionalProperties;
|
||||||
|
use super::additional_property::AdditionalPropertyValue;
|
||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
use crate::compare::ElispFact;
|
|
||||||
use crate::types::Document;
|
use crate::types::Document;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmDocument {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmDocument<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "CATEGORY")]
|
||||||
additional_properties: Vec<(String, &'s str)>,
|
pub(crate) category: Option<String>,
|
||||||
pub(crate) children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
category: Option<&'p str>,
|
|
||||||
pub(crate) path: Option<PathBuf>,
|
pub(crate) path: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmDocument<'s, 'p>,
|
WasmDocument,
|
||||||
Document<'s>,
|
Document<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Document(original) },
|
||||||
|
{ "org-data".into() },
|
||||||
{
|
{
|
||||||
let category = original.category.as_ref().map(String::as_str);
|
let category = original.category.as_deref();
|
||||||
let path = original.path.clone();
|
let path = original.path.clone();
|
||||||
|
|
||||||
let additional_properties: Vec<(String, &str)> = original
|
let mut additional_properties = AdditionalProperties::default();
|
||||||
.get_additional_properties()
|
for (name, val) in original.get_additional_properties().map(|node_property| {
|
||||||
.map(|node_property| {
|
(
|
||||||
(
|
node_property.property_name.to_uppercase(),
|
||||||
format!(":{}", node_property.property_name.to_uppercase()),
|
AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("").to_owned()),
|
||||||
node_property.value.unwrap_or(""),
|
)
|
||||||
)
|
}) {
|
||||||
})
|
additional_properties.properties.insert(name, val);
|
||||||
.collect();
|
}
|
||||||
|
|
||||||
let children = original
|
let children = original
|
||||||
.zeroth_section
|
.zeroth_section
|
||||||
@@ -48,34 +48,22 @@ to_wasm!(
|
|||||||
.map(|child| {
|
.map(|child| {
|
||||||
child
|
child
|
||||||
.to_wasm(wasm_context.clone())
|
.to_wasm(wasm_context.clone())
|
||||||
.map(Into::<WasmAstNode<'_, '_>>::into)
|
.map(Into::<WasmAstNode>::into)
|
||||||
})
|
})
|
||||||
.chain(original.children.iter().map(|child| {
|
.chain(original.children.iter().map(|child| {
|
||||||
child
|
child
|
||||||
.to_wasm(wasm_context.clone())
|
.to_wasm(wasm_context.clone())
|
||||||
.map(Into::<WasmAstNode<'_, '_>>::into)
|
.map(Into::<WasmAstNode>::into)
|
||||||
}))
|
}))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
Ok(WasmDocument {
|
Ok((
|
||||||
standard_properties,
|
|
||||||
additional_properties,
|
|
||||||
children,
|
children,
|
||||||
category,
|
WasmDocument {
|
||||||
path,
|
additional_properties,
|
||||||
})
|
category: category.map(str::to_owned),
|
||||||
|
path,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmDocument<'s, 'p> {
|
|
||||||
fn into(self) -> WasmAstNode<'s, 'p> {
|
|
||||||
WasmAstNode::Document(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "wasm_test")]
|
|
||||||
impl<'s, 'p> ElispFact<'s> for WasmDocument<'s, 'p> {
|
|
||||||
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
|
|
||||||
"org-data".into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,30 +1,51 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::Drawer;
|
use crate::types::Drawer;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmDrawer {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmDrawer<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "drawer-name")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) drawer_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmDrawer<'s, 'p>,
|
WasmDrawer,
|
||||||
Drawer<'s>,
|
Drawer<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Drawer(original) },
|
||||||
|
{ "drawer".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmDrawer {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmDrawer {
|
||||||
|
additional_properties,
|
||||||
|
drawer_name: original.drawer_name.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,53 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::DynamicBlock;
|
use crate::types::DynamicBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmDynamicBlock {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmDynamicBlock<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "block-name")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) block_name: String,
|
||||||
|
pub(crate) arguments: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmDynamicBlock<'s, 'p>,
|
WasmDynamicBlock,
|
||||||
DynamicBlock<'s>,
|
DynamicBlock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::DynamicBlock(original) },
|
||||||
|
{ "dynamic-block".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmDynamicBlock {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmDynamicBlock {
|
||||||
|
additional_properties,
|
||||||
|
block_name: original.block_name.to_owned(),
|
||||||
|
arguments: original.parameters.map(|s| s.to_owned()),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,49 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
|
use super::headline::Noop;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Entity;
|
use crate::types::Entity;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmEntity {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) name: String,
|
||||||
pub struct WasmEntity<'s, 'p> {
|
pub(crate) latex: String,
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "latex-math-p")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) latex_math_mode: bool,
|
||||||
|
pub(crate) html: String,
|
||||||
|
pub(crate) ascii: String,
|
||||||
|
pub(crate) latin1: Noop,
|
||||||
|
#[serde(rename = "utf-8")]
|
||||||
|
pub(crate) utf8: String,
|
||||||
|
#[serde(rename = "use-brackets-p")]
|
||||||
|
pub(crate) use_brackets: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmEntity<'s, 'p>,
|
WasmEntity,
|
||||||
Entity<'s>,
|
Entity<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Entity(original) },
|
||||||
|
{ "entity".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmEntity {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmEntity {
|
||||||
})
|
name: original.name.to_owned(),
|
||||||
|
latex: original.latex.to_owned(),
|
||||||
|
latex_math_mode: original.latex_math_mode,
|
||||||
|
html: original.html.to_owned(),
|
||||||
|
ascii: original.ascii.to_owned(),
|
||||||
|
latin1: Noop {},
|
||||||
|
utf8: original.utf8.to_owned(),
|
||||||
|
use_brackets: original.use_brackets,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,75 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
use super::src_block::WasmNumberLines;
|
||||||
|
use super::src_block::WasmNumberLinesWrapper;
|
||||||
|
use super::src_block::WasmRetainLabels;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use crate::types::CharOffsetInLine;
|
||||||
use crate::types::ExampleBlock;
|
use crate::types::ExampleBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::types::RetainLabels;
|
||||||
|
use crate::types::SwitchNumberLines;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmExampleBlock {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmExampleBlock<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) value: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) switches: Option<String>,
|
||||||
|
#[serde(rename = "number-lines")]
|
||||||
|
pub(crate) number_lines: Option<WasmNumberLinesWrapper>,
|
||||||
|
#[serde(rename = "preserve-indent")]
|
||||||
|
pub(crate) preserve_indent: Option<CharOffsetInLine>,
|
||||||
|
#[serde(rename = "retain-labels")]
|
||||||
|
pub(crate) retain_labels: WasmRetainLabels,
|
||||||
|
#[serde(rename = "use-labels")]
|
||||||
|
pub(crate) use_labels: bool,
|
||||||
|
#[serde(rename = "label-fmt")]
|
||||||
|
pub(crate) label_format: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmExampleBlock<'s, 'p>,
|
WasmExampleBlock,
|
||||||
ExampleBlock<'s>,
|
ExampleBlock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::ExampleBlock(original) },
|
||||||
|
{ "example-block".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmExampleBlock {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmExampleBlock {
|
||||||
|
additional_properties,
|
||||||
|
value: original.get_value().into_owned(),
|
||||||
|
switches: original.switches.map(|s| s.to_owned()),
|
||||||
|
number_lines: match original.number_lines {
|
||||||
|
None => None,
|
||||||
|
Some(SwitchNumberLines::New(n)) => Some(WasmNumberLinesWrapper {
|
||||||
|
inner: WasmNumberLines::New(n),
|
||||||
|
}),
|
||||||
|
Some(SwitchNumberLines::Continued(n)) => Some(WasmNumberLinesWrapper {
|
||||||
|
inner: WasmNumberLines::Continued(n),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
preserve_indent: original.preserve_indent,
|
||||||
|
retain_labels: match original.retain_labels {
|
||||||
|
RetainLabels::No => WasmRetainLabels::YesNo(false),
|
||||||
|
RetainLabels::Yes => WasmRetainLabels::YesNo(true),
|
||||||
|
RetainLabels::Keep(n) => WasmRetainLabels::Keep(n),
|
||||||
|
},
|
||||||
|
use_labels: original.use_labels,
|
||||||
|
label_format: original.label_format.map(|s| s.to_owned()),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,43 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::ExportBlock;
|
use crate::types::ExportBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmExportBlock {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmExportBlock<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "type")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) export_type: Option<String>,
|
||||||
|
pub(crate) value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmExportBlock<'s, 'p>,
|
WasmExportBlock,
|
||||||
ExportBlock<'s>,
|
ExportBlock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::ExportBlock(original) },
|
||||||
|
{ "export-block".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmExportBlock {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmExportBlock {
|
||||||
|
additional_properties,
|
||||||
|
export_type: original.get_export_type(),
|
||||||
|
value: original.get_value().into_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,34 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::ExportSnippet;
|
use crate::types::ExportSnippet;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmExportSnippet {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "back-end")]
|
||||||
pub struct WasmExportSnippet<'s, 'p> {
|
pub(crate) backend: String,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) value: Option<String>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmExportSnippet<'s, 'p>,
|
WasmExportSnippet,
|
||||||
ExportSnippet<'s>,
|
ExportSnippet<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::ExportSnippet(original) },
|
||||||
|
{ "export-snippet".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmExportSnippet {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmExportSnippet {
|
||||||
})
|
backend: original.backend.to_owned(),
|
||||||
|
value: original.contents.map(|s| s.to_owned()),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,42 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::FixedWidthArea;
|
use crate::types::FixedWidthArea;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmFixedWidthArea {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmFixedWidthArea<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) value: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmFixedWidthArea<'s, 'p>,
|
WasmFixedWidthArea,
|
||||||
FixedWidthArea<'s>,
|
FixedWidthArea<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::FixedWidthArea(original) },
|
||||||
|
{ "fixed-width".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmFixedWidthArea {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let value = original.get_value();
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmFixedWidthArea {
|
||||||
|
additional_properties,
|
||||||
|
value,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,54 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
|
use super::headline::Noop;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::types::FootnoteDefinition;
|
use crate::types::FootnoteDefinition;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmFootnoteDefinition {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmFootnoteDefinition<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) label: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
#[serde(rename = "pre-blank")]
|
||||||
|
pub(crate) pre_blank: Noop,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmFootnoteDefinition<'s, 'p>,
|
WasmFootnoteDefinition,
|
||||||
FootnoteDefinition<'s>,
|
FootnoteDefinition<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::FootnoteDefinition(original) },
|
||||||
|
{ "footnote-definition".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmFootnoteDefinition {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmFootnoteDefinition {
|
||||||
|
additional_properties,
|
||||||
|
label: original.label.to_owned(),
|
||||||
|
pre_blank: Noop {},
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,49 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::FootnoteReference;
|
use crate::types::FootnoteReference;
|
||||||
|
use crate::types::FootnoteReferenceType;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmFootnoteReference {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) label: Option<String>,
|
||||||
pub struct WasmFootnoteReference<'s, 'p> {
|
#[serde(rename = "type")]
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) footnote_reference_type: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmFootnoteReference<'s, 'p>,
|
WasmFootnoteReference,
|
||||||
FootnoteReference<'s>,
|
FootnoteReference<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::FootnoteReference(original) },
|
||||||
|
{ "footnote-reference".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmFootnoteReference {
|
let children = original
|
||||||
standard_properties,
|
.definition
|
||||||
children: Vec::new(),
|
.iter()
|
||||||
})
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmFootnoteReference {
|
||||||
|
label: original.label.map(|s| s.to_owned()),
|
||||||
|
footnote_reference_type: match original.get_type() {
|
||||||
|
FootnoteReferenceType::Standard => "standard",
|
||||||
|
FootnoteReferenceType::Inline => "inline",
|
||||||
|
}
|
||||||
|
.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,36 +1,140 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use super::AdditionalPropertyValue;
|
||||||
use crate::types::Heading;
|
use crate::types::Heading;
|
||||||
|
use crate::types::HeadlineLevel;
|
||||||
|
use crate::types::PriorityCookie;
|
||||||
|
use crate::types::TodoKeywordType;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmHeadline {
|
||||||
#[serde(rename = "headline")]
|
#[serde(flatten)]
|
||||||
pub struct WasmHeadline<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) level: HeadlineLevel,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) tags: Vec<String>,
|
||||||
|
#[serde(rename = "todo-keyword")]
|
||||||
|
pub(crate) todo_keyword: Option<String>,
|
||||||
|
#[serde(rename = "todo-type")]
|
||||||
|
pub(crate) todo_type: Option<String>,
|
||||||
|
pub(crate) title: Vec<WasmAstNode>,
|
||||||
|
pub(crate) priority: Option<PriorityCookie>,
|
||||||
|
#[serde(rename = "archivedp")]
|
||||||
|
pub(crate) is_archived: bool,
|
||||||
|
#[serde(rename = "commentedp")]
|
||||||
|
pub(crate) is_comment: bool,
|
||||||
|
#[serde(rename = "raw-value")]
|
||||||
|
pub(crate) raw_value: String,
|
||||||
|
#[serde(rename = "footnote-section-p")]
|
||||||
|
pub(crate) is_footnote_section: bool,
|
||||||
|
pub(crate) scheduled: Option<Box<WasmAstNode>>,
|
||||||
|
pub(crate) deadline: Option<Box<WasmAstNode>>,
|
||||||
|
pub(crate) closed: Option<Box<WasmAstNode>>,
|
||||||
|
#[serde(rename = "pre-blank")]
|
||||||
|
pub(crate) pre_blank: Noop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "noop")]
|
||||||
|
pub struct Noop {}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmHeadline<'s, 'p>,
|
WasmHeadline,
|
||||||
Heading<'s>,
|
Heading<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Headline(original) },
|
||||||
|
{ "headline".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmHeadline {
|
let mut additional_properties = AdditionalProperties::default();
|
||||||
standard_properties,
|
for (name, val) in original.get_additional_properties().map(|node_property| {
|
||||||
children: Vec::new(),
|
(
|
||||||
})
|
node_property.property_name.to_uppercase(),
|
||||||
|
AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("").to_owned()),
|
||||||
|
)
|
||||||
|
}) {
|
||||||
|
additional_properties.properties.insert(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmHeadline {
|
||||||
|
additional_properties,
|
||||||
|
level: original.level,
|
||||||
|
tags: original.tags.iter().map(|tag| (*tag).to_owned()).collect(),
|
||||||
|
todo_keyword: original
|
||||||
|
.todo_keyword
|
||||||
|
.as_ref()
|
||||||
|
.map(|(_, keyword)| (*keyword).to_owned()),
|
||||||
|
todo_type: original
|
||||||
|
.todo_keyword
|
||||||
|
.as_ref()
|
||||||
|
.map(|(keyword, _)| match keyword {
|
||||||
|
TodoKeywordType::Done => "done".to_owned(),
|
||||||
|
TodoKeywordType::Todo => "todo".to_owned(),
|
||||||
|
}),
|
||||||
|
title: original
|
||||||
|
.title
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?,
|
||||||
|
priority: original.priority_cookie,
|
||||||
|
is_archived: original.is_archived,
|
||||||
|
is_comment: original.is_comment,
|
||||||
|
raw_value: original.get_raw_value(),
|
||||||
|
is_footnote_section: original.is_footnote_section,
|
||||||
|
scheduled: original
|
||||||
|
.scheduled
|
||||||
|
.as_ref()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.map_or(Ok(None), |r| r.map(Some))?
|
||||||
|
.map(Box::new),
|
||||||
|
deadline: original
|
||||||
|
.deadline
|
||||||
|
.as_ref()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.map_or(Ok(None), |r| r.map(Some))?
|
||||||
|
.map(Box::new),
|
||||||
|
closed: original
|
||||||
|
.closed
|
||||||
|
.as_ref()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.map_or(Ok(None), |r| r.map(Some))?
|
||||||
|
.map(Box::new),
|
||||||
|
pre_blank: Noop {},
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmHeadline<'s, 'p> {
|
|
||||||
fn into(self) -> WasmAstNode<'s, 'p> {
|
|
||||||
WasmAstNode::Headline(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,30 +1,38 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::HorizontalRule;
|
use crate::types::HorizontalRule;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmHorizontalRule {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmHorizontalRule<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmHorizontalRule<'s, 'p>,
|
WasmHorizontalRule,
|
||||||
HorizontalRule<'s>,
|
HorizontalRule<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::HorizontalRule(original) },
|
||||||
|
{ "horizontal-rule".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmHorizontalRule {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmHorizontalRule {
|
||||||
|
additional_properties,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,41 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::InlineBabelCall;
|
use crate::types::InlineBabelCall;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmInlineBabelCall {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) call: String,
|
||||||
pub struct WasmInlineBabelCall<'s, 'p> {
|
#[serde(rename = "inside-header")]
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) inside_header: Option<String>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) arguments: Option<String>,
|
||||||
|
#[serde(rename = "end-header")]
|
||||||
|
pub(crate) end_header: Option<String>,
|
||||||
|
pub(crate) value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmInlineBabelCall<'s, 'p>,
|
WasmInlineBabelCall,
|
||||||
InlineBabelCall<'s>,
|
InlineBabelCall<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::InlineBabelCall(original) },
|
||||||
|
{ "inline-babel-call".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmInlineBabelCall {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmInlineBabelCall {
|
||||||
})
|
call: original.call.to_owned(),
|
||||||
|
inside_header: original.inside_header.map(|s| s.to_owned()),
|
||||||
|
arguments: original.arguments.map(|s| s.to_owned()),
|
||||||
|
end_header: original.end_header.map(|s| s.to_owned()),
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,35 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::InlineSourceBlock;
|
use crate::types::InlineSourceBlock;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmInlineSourceBlock {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) language: String,
|
||||||
pub struct WasmInlineSourceBlock<'s, 'p> {
|
pub(crate) value: String,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) parameters: Option<String>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmInlineSourceBlock<'s, 'p>,
|
WasmInlineSourceBlock,
|
||||||
InlineSourceBlock<'s>,
|
InlineSourceBlock<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::InlineSourceBlock(original) },
|
||||||
|
{ "inline-src-block".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmInlineSourceBlock {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmInlineSourceBlock {
|
||||||
})
|
language: original.language.to_owned(),
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
parameters: original.parameters.map(str::to_owned),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,34 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::Italic;
|
use crate::types::Italic;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmItalic {}
|
||||||
#[serde(rename = "org-data")]
|
|
||||||
pub struct WasmItalic<'s, 'p> {
|
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmItalic<'s, 'p>,
|
WasmItalic,
|
||||||
Italic<'s>,
|
Italic<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Italic(original) },
|
||||||
|
{ "italic".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmItalic {
|
let children = original
|
||||||
standard_properties,
|
.children
|
||||||
children: Vec::new(),
|
.iter()
|
||||||
})
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((children, WasmItalic {}))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,42 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmKeyword {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmKeyword<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) key: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmKeyword<'s, 'p>,
|
WasmKeyword,
|
||||||
Keyword<'s>,
|
Keyword<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Keyword(original) },
|
||||||
|
{ "keyword".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmKeyword {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmKeyword {
|
||||||
|
additional_properties,
|
||||||
|
key: original.key.to_uppercase(),
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,40 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::LatexEnvironment;
|
use crate::types::LatexEnvironment;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmLatexEnvironment {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmLatexEnvironment<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) value: String,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmLatexEnvironment<'s, 'p>,
|
WasmLatexEnvironment,
|
||||||
LatexEnvironment<'s>,
|
LatexEnvironment<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::LatexEnvironment(original) },
|
||||||
|
{ "latex-environment".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmLatexEnvironment {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
Ok((
|
||||||
|
Vec::new(),
|
||||||
|
WasmLatexEnvironment {
|
||||||
|
additional_properties,
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::LatexFragment;
|
use crate::types::LatexFragment;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmLatexFragment {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) value: String,
|
||||||
pub struct WasmLatexFragment<'s, 'p> {
|
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmLatexFragment<'s, 'p>,
|
WasmLatexFragment,
|
||||||
LatexFragment<'s>,
|
LatexFragment<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::LatexFragment(original) },
|
||||||
|
{ "latex-fragment".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmLatexFragment {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmLatexFragment {
|
||||||
})
|
value: original.value.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,22 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::LineBreak;
|
use crate::types::LineBreak;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmLineBreak {}
|
||||||
#[serde(rename = "org-data")]
|
|
||||||
pub struct WasmLineBreak<'s, 'p> {
|
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmLineBreak<'s, 'p>,
|
WasmLineBreak,
|
||||||
LineBreak<'s>,
|
LineBreak<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::LineBreak(original) },
|
||||||
{
|
{ "line-break".into() },
|
||||||
Ok(WasmLineBreak {
|
{ Ok((Vec::new(), WasmLineBreak {},)) }
|
||||||
standard_properties,
|
|
||||||
children: Vec::new(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,21 +2,58 @@
|
|||||||
///
|
///
|
||||||
/// This exists to make changing the type signature easier.
|
/// This exists to make changing the type signature easier.
|
||||||
macro_rules! to_wasm {
|
macro_rules! to_wasm {
|
||||||
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
|
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $fnbody:tt) => {
|
||||||
impl<'s, 'p> ToWasm<'p> for $istruct {
|
impl<'s> ToWasm for $istruct {
|
||||||
type Output = $ostruct;
|
type Output = $ostruct;
|
||||||
|
|
||||||
fn to_wasm(
|
fn to_wasm(
|
||||||
&'p self,
|
&self,
|
||||||
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
|
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
|
||||||
) -> Result<Self::Output, crate::error::CustomError> {
|
) -> Result<Self::Output, crate::error::CustomError> {
|
||||||
let $original = self;
|
let $original = self;
|
||||||
let $standard_properties =
|
#[allow(unused_braces)]
|
||||||
self.to_wasm_standard_properties($wasm_context.clone())?;
|
|
||||||
$fnbody
|
$fnbody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $toastnodebody:tt, $elispnamebody:tt, $fnbody:tt) => {
|
||||||
|
impl<'s> ToWasm for $istruct {
|
||||||
|
type Output = crate::wasm::ast_node::WasmAstNodeWrapper<$ostruct>;
|
||||||
|
|
||||||
|
fn to_wasm(
|
||||||
|
&self,
|
||||||
|
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
|
||||||
|
) -> Result<Self::Output, crate::error::CustomError> {
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
let $original = self;
|
||||||
|
let standard_properties =
|
||||||
|
self.to_wasm_standard_properties($wasm_context.clone())?;
|
||||||
|
|
||||||
|
$fnbody.map(
|
||||||
|
|(children, inner)| crate::wasm::ast_node::WasmAstNodeWrapper {
|
||||||
|
ast_node: inner.get_elisp_name().into_owned(),
|
||||||
|
standard_properties,
|
||||||
|
children,
|
||||||
|
properties: inner,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<crate::wasm::ast_node::WasmAstNodeWrapper<$ostruct>> for WasmAstNode {
|
||||||
|
fn from($original: crate::wasm::ast_node::WasmAstNodeWrapper<$ostruct>) -> Self {
|
||||||
|
let ret = $toastnodebody;
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'s> crate::util::elisp_fact::ElispFact<'s> for $ostruct {
|
||||||
|
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
|
||||||
|
let ret = $elispnamebody;
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use to_wasm;
|
pub(crate) use to_wasm;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
mod additional_property;
|
||||||
mod angle_link;
|
mod angle_link;
|
||||||
mod ast_node;
|
mod ast_node;
|
||||||
mod babel_call;
|
mod babel_call;
|
||||||
@@ -62,8 +63,14 @@ mod underline;
|
|||||||
mod verbatim;
|
mod verbatim;
|
||||||
mod verse_block;
|
mod verse_block;
|
||||||
|
|
||||||
|
pub use additional_property::AdditionalProperties;
|
||||||
|
pub use additional_property::AdditionalPropertyValue;
|
||||||
pub use ast_node::WasmAstNode;
|
pub use ast_node::WasmAstNode;
|
||||||
|
#[cfg(feature = "wasm_test")]
|
||||||
|
pub use ast_node::WasmAstNodeWrapper;
|
||||||
|
#[cfg(feature = "wasm_test")]
|
||||||
pub use document::WasmDocument;
|
pub use document::WasmDocument;
|
||||||
pub use parse_result::ParseResult;
|
pub use parse_result::ParseResult;
|
||||||
|
pub(crate) use standard_properties::WasmStandardProperties;
|
||||||
pub use to_wasm::ToWasm;
|
pub use to_wasm::ToWasm;
|
||||||
pub use to_wasm::ToWasmContext;
|
pub use to_wasm::ToWasmContext;
|
||||||
|
|||||||
@@ -1,30 +1,33 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::NodeProperty;
|
use crate::types::NodeProperty;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmNodeProperty {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) key: String,
|
||||||
pub struct WasmNodeProperty<'s, 'p> {
|
pub(crate) value: Option<String>,
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmNodeProperty<'s, 'p>,
|
WasmNodeProperty,
|
||||||
NodeProperty<'s>,
|
NodeProperty<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::NodeProperty(original) },
|
||||||
|
{ "node-property".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmNodeProperty {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmNodeProperty {
|
||||||
})
|
key: original.property_name.to_owned(),
|
||||||
|
value: original.value.map(|s| s.to_owned()),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,35 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use crate::types::OrgMacro;
|
use crate::types::OrgMacro;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmOrgMacro {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) key: String,
|
||||||
pub struct WasmOrgMacro<'s, 'p> {
|
pub(crate) value: String,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) args: Vec<String>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmOrgMacro<'s, 'p>,
|
WasmOrgMacro,
|
||||||
OrgMacro<'s>,
|
OrgMacro<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::OrgMacro(original) },
|
||||||
|
{ "macro".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmOrgMacro {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmOrgMacro {
|
||||||
})
|
key: original.key.to_lowercase(),
|
||||||
|
value: original.value.to_owned(),
|
||||||
|
args: original.get_args().map(|s| s.into_owned()).collect(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,48 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmParagraph {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmParagraph<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmParagraph<'s, 'p>,
|
WasmParagraph,
|
||||||
Paragraph<'s>,
|
Paragraph<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::Paragraph(original) },
|
||||||
|
{ "paragraph".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmParagraph {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmParagraph {
|
||||||
|
additional_properties,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNodeWrapper;
|
||||||
use super::document::WasmDocument;
|
use super::document::WasmDocument;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "status", content = "content")]
|
#[serde(tag = "status", content = "content")]
|
||||||
pub enum ParseResult<'s, 'p> {
|
pub enum ParseResult {
|
||||||
#[serde(rename = "success")]
|
#[serde(rename = "success")]
|
||||||
Success(WasmDocument<'s, 'p>),
|
Success(WasmAstNodeWrapper<WasmDocument>),
|
||||||
|
|
||||||
#[serde(rename = "error")]
|
#[serde(rename = "error")]
|
||||||
Error(String),
|
Error(String),
|
||||||
|
|||||||
@@ -1,30 +1,52 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::types::LinkType;
|
||||||
use crate::types::PlainLink;
|
use crate::types::PlainLink;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
#[serde(tag = "format")]
|
||||||
#[serde(rename = "org-data")]
|
#[serde(rename = "plain")]
|
||||||
pub struct WasmPlainLink<'s, 'p> {
|
pub struct WasmPlainLink {
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "type")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) link_type: String,
|
||||||
|
pub(crate) path: String,
|
||||||
|
#[serde(rename = "raw-link")]
|
||||||
|
pub(crate) raw_link: String,
|
||||||
|
pub(crate) application: Option<String>,
|
||||||
|
#[serde(rename = "search-option")]
|
||||||
|
pub(crate) search_option: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmPlainLink<'s, 'p>,
|
WasmPlainLink,
|
||||||
PlainLink<'s>,
|
PlainLink<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::PlainLink(original) },
|
||||||
|
{ "link".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmPlainLink {
|
Ok((
|
||||||
standard_properties,
|
Vec::new(),
|
||||||
children: Vec::new(),
|
WasmPlainLink {
|
||||||
})
|
link_type: match &original.link_type {
|
||||||
|
LinkType::File => "file".to_owned(),
|
||||||
|
LinkType::Protocol(protocol) => protocol.clone().into_owned(),
|
||||||
|
LinkType::Id => "id".to_owned(),
|
||||||
|
LinkType::CustomId => "custom-id".to_owned(),
|
||||||
|
LinkType::CodeRef => "coderef".to_owned(),
|
||||||
|
LinkType::Fuzzy => "fuzzy".to_owned(),
|
||||||
|
},
|
||||||
|
path: original.path.to_owned(),
|
||||||
|
raw_link: original.raw_link.to_owned(),
|
||||||
|
application: original.application.map(str::to_owned),
|
||||||
|
search_option: original.search_option.map(str::to_owned),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,57 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::PlainList;
|
use crate::types::PlainList;
|
||||||
|
use crate::types::PlainListType;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmPlainList {
|
||||||
#[serde(rename = "org-data")]
|
#[serde(flatten)]
|
||||||
pub struct WasmPlainList<'s, 'p> {
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
standard_properties: WasmStandardProperties,
|
#[serde(rename = "type")]
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) list_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmPlainList<'s, 'p>,
|
WasmPlainList,
|
||||||
PlainList<'s>,
|
PlainList<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::PlainList(original) },
|
||||||
|
{ "plain-list".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmPlainList {
|
let additional_properties = original
|
||||||
standard_properties,
|
.get_affiliated_keywords()
|
||||||
children: Vec::new(),
|
.to_wasm(wasm_context.clone())?;
|
||||||
})
|
|
||||||
|
let children = original
|
||||||
|
.children
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmPlainList {
|
||||||
|
additional_properties,
|
||||||
|
list_type: match original.list_type {
|
||||||
|
PlainListType::Unordered => "unordered",
|
||||||
|
PlainListType::Ordered => "ordered",
|
||||||
|
PlainListType::Descriptive => "descriptive",
|
||||||
|
}
|
||||||
|
.to_owned(),
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,30 +1,68 @@
|
|||||||
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::standard_properties::WasmStandardProperties;
|
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::types::CheckboxType;
|
||||||
use crate::types::PlainListItem;
|
use crate::types::PlainListItem;
|
||||||
|
use crate::types::PlainListItemCounter;
|
||||||
|
use crate::types::PlainListItemPreBlank;
|
||||||
|
use crate::util::elisp_fact::ElispFact;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
use crate::wasm::WasmAstNode;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(tag = "ast_node")]
|
pub struct WasmPlainListItem {
|
||||||
#[serde(rename = "org-data")]
|
pub(crate) tag: Vec<WasmAstNode>,
|
||||||
pub struct WasmPlainListItem<'s, 'p> {
|
pub(crate) bullet: String,
|
||||||
standard_properties: WasmStandardProperties,
|
pub(crate) counter: Option<PlainListItemCounter>,
|
||||||
children: Vec<WasmAstNode<'s, 'p>>,
|
pub(crate) checkbox: Option<String>,
|
||||||
|
#[serde(rename = "pre-blank")]
|
||||||
|
pub(crate) pre_blank: PlainListItemPreBlank,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
WasmPlainListItem<'s, 'p>,
|
WasmPlainListItem,
|
||||||
PlainListItem<'s>,
|
PlainListItem<'s>,
|
||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
standard_properties,
|
{ WasmAstNode::PlainListItem(original) },
|
||||||
|
{ "item".into() },
|
||||||
{
|
{
|
||||||
Ok(WasmPlainListItem {
|
let children = original
|
||||||
standard_properties,
|
.children
|
||||||
children: Vec::new(),
|
.iter()
|
||||||
})
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
|
Ok((
|
||||||
|
children,
|
||||||
|
WasmPlainListItem {
|
||||||
|
tag: original
|
||||||
|
.tag
|
||||||
|
.iter()
|
||||||
|
.map(|child| {
|
||||||
|
child
|
||||||
|
.to_wasm(wasm_context.clone())
|
||||||
|
.map(Into::<WasmAstNode>::into)
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>()?,
|
||||||
|
bullet: original.bullet.to_owned(),
|
||||||
|
counter: original.counter,
|
||||||
|
checkbox: original.checkbox.as_ref().map(|(checkbox_type, _)| {
|
||||||
|
match checkbox_type {
|
||||||
|
CheckboxType::On => "on",
|
||||||
|
CheckboxType::Trans => "trans",
|
||||||
|
CheckboxType::Off => "off",
|
||||||
|
}
|
||||||
|
.to_owned()
|
||||||
|
}),
|
||||||
|
pre_blank: original.pre_blank,
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user