Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDAV Imports #1

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 280 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
ALPINE_GIT = "alpine/git:latest"
OC_CI_ALPINE = "owncloudci/alpine:latest"
OC_CI_BAZEL_BUILDIFIER = "owncloudci/bazel-buildifier"
OC_CI_NODEJS = "owncloudci/nodejs:18"
PLUGINS_DOCKER = "plugins/docker:20.14"
PLUGINS_GIT_ACTION = "plugins/git-action:1"
PLUGINS_GITHUB_RELEASE = "plugins/github-release:1"

def main(ctx):
before = beforePipelines(ctx)

stages = pipelinesDependsOn(stagePipelines(ctx), before)

if (stages == False):
print("Errors detected. Review messages above.")
return []

after = pipelinesDependsOn(afterPipelines(ctx), stages)

pipelines = before + stages + after

pipelineSanityChecks(ctx, pipelines)
return pipelines

def beforePipelines(ctx):
return checkStarlark() + lint(ctx)

def stagePipelines(ctx):
return []

def afterPipelines(ctx):
return build(ctx)

def lint(ctx):
pipelines = []

result = {
"kind": "pipeline",
"type": "docker",
"name": "lint",
"steps": [{
"name": "lint",
"image": OC_CI_NODEJS,
"commands": [
"yarn set version 3.6.1",
"yarn install --immutable",
"yarn lint",
],
}],
"trigger": {
"ref": [
"refs/heads/main",
"refs/heads/webdav-imports",
"refs/tags/**",
"refs/pull/**",
],
},
}

pipelines.append(result)

return pipelines

def build(ctx):
pipelines = []
steps = buildRelease(ctx) + buildDockerImage(ctx)

result = {
"kind": "pipeline",
"type": "docker",
"name": "build",
"steps": steps,
"trigger": {
"ref": [
"refs/heads/main",
"refs/heads/webdav-imports",
"refs/tags/**",
"refs/pull/**",
],
},
}

pipelines.append(result)

return pipelines

def buildDockerImage(ctx):
return [
{
"name": "docker",
"image": PLUGINS_DOCKER,
"settings": {
"username": {
"from_secret": "docker_username",
},
"password": {
"from_secret": "docker_password",
},
"auto_tag": ctx.build.event == "tag",
"dockerfile": "Dockerfile",
"repo": "owncloud/uppy-companion",
"dry_run": ctx.build.event != "tag",
},
"depends_on": ["clone"],
},
]

def determineReleaseVersion(ctx):
return ctx.build.ref.replace("refs/tags/v", "")

def buildRelease(ctx):
version = determineReleaseVersion(ctx)

return [
{
"name": "build",
"image": OC_CI_NODEJS,
"commands": [
"yarn set version 3.6.1",
"yarn install --immutable",
"yarn run build",
"yarn workspaces foreach pack",
"./collect_release_artifacts.sh",
],
"depends_on": ["clone"],
},
{
"name": "publish",
"image": PLUGINS_GITHUB_RELEASE,
"settings": {
"api_key": {
"from_secret": "github_token",
},
"files": [
"release/*",
],
"checksum": [
"md5",
"sha256",
],
"title": ctx.build.ref.replace("refs/tags/v", ""),
"overwrite": True,
},
"depends_on": ["build"],
"when": {
"ref": [
"refs/tags/**",
],
},
},
]

def checkStarlark():
return [{
"kind": "pipeline",
"type": "docker",
"name": "check-starlark",
"steps": [
{
"name": "format-check-starlark",
"image": OC_CI_BAZEL_BUILDIFIER,
"commands": [
"buildifier --mode=check .drone.star",
],
},
{
"name": "show-diff",
"image": OC_CI_BAZEL_BUILDIFIER,
"commands": [
"buildifier --mode=fix .drone.star",
"git diff",
],
"when": {
"status": [
"failure",
],
},
},
],
"trigger": {
"ref": [
"refs/pull/**",
],
},
}]

def pipelineDependsOn(pipeline, dependant_pipelines):
if "depends_on" in pipeline.keys():
pipeline["depends_on"] = pipeline["depends_on"] + getPipelineNames(dependant_pipelines)
else:
pipeline["depends_on"] = getPipelineNames(dependant_pipelines)
return pipeline

def pipelinesDependsOn(pipelines, dependant_pipelines):
pipes = []
for pipeline in pipelines:
pipes.append(pipelineDependsOn(pipeline, dependant_pipelines))

return pipes

def getPipelineNames(pipelines = []):
"""getPipelineNames returns names of pipelines as a string array

Args:
pipelines: array of drone pipelines

Returns:
names of the given pipelines as string array
"""
names = []
for pipeline in pipelines:
names.append(pipeline["name"])
return names

def pipelineSanityChecks(ctx, pipelines):
"""pipelineSanityChecks helps the CI developers to find errors before running it

These sanity checks are only executed on when converting starlark to yaml.
Error outputs are only visible when the conversion is done with the drone cli.

Args:
ctx: drone passes a context with information which the pipeline can be adapted to
pipelines: pipelines to be checked, normally you should run this on the return value of main()

Returns:
none
"""

# check if name length of pipeline and steps are exceeded.
max_name_length = 50
for pipeline in pipelines:
pipeline_name = pipeline["name"]
if len(pipeline_name) > max_name_length:
print("Error: pipeline name %s is longer than 50 characters" % (pipeline_name))

for step in pipeline["steps"]:
step_name = step["name"]
if len(step_name) > max_name_length:
print("Error: step name %s in pipeline %s is longer than 50 characters" % (step_name, pipeline_name))

# check for non existing depends_on
possible_depends = []
for pipeline in pipelines:
possible_depends.append(pipeline["name"])

for pipeline in pipelines:
if "depends_on" in pipeline.keys():
for depends in pipeline["depends_on"]:
if not depends in possible_depends:
print("Error: depends_on %s for pipeline %s is not defined" % (depends, pipeline["name"]))

# check for non declared volumes
for pipeline in pipelines:
pipeline_volumes = []
if "volumes" in pipeline.keys():
for volume in pipeline["volumes"]:
pipeline_volumes.append(volume["name"])

for step in pipeline["steps"]:
if "volumes" in step.keys():
for volume in step["volumes"]:
if not volume["name"] in pipeline_volumes:
print("Warning: volume %s for step %s is not defined in pipeline %s" % (volume["name"], step["name"], pipeline["name"]))

# list used docker images
print("")
print("List of used docker images:")

images = {}

for pipeline in pipelines:
for step in pipeline["steps"]:
image = step["image"]
if image in images.keys():
images[image] = images[image] + 1
else:
images[image] = 1

for image in images.keys():
print(" %sx\t%s" % (images[image], image))
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ COMPANION_ZOOM_SECRET=***
COMPANION_UNSPLASH_KEY=***
COMPANION_UNSPLASH_SECRET=***

COMPANION_ONEDRIVE_KEY=***
COMPANION_ONEDRIVE_SECRET=****

COMPANION_WEBDAV_KEY=***
COMPANION_WEBDAV_SECRET=***

# Development environment
# =======================

Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ module.exports = {
'packages/@uppy/utils/src/**/*.js',
'packages/@uppy/vue/src/**/*.js',
'packages/@uppy/webcam/src/**/*.js',
'packages/@uppy/webdav/src/**/*.js',
'packages/@uppy/xhr-upload/src/**/*.js',
'packages/@uppy/zoom/src/**/*.js',
],
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ issues.txt
# companion deployment files
transloadit-cluster-kubeconfig.yaml
companion-env.yml

.drone.yml
12 changes: 12 additions & 0 deletions .yarn/patches/webdav-npm-5.2.2-791e72c3de.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/dist/node/types.d.ts b/dist/node/types.d.ts
index f83ab515d230cb299a8aed4e13d6ad867efe2e61..346c3b762e6364e3bb016bc4fb50bc56fd649a56 100644
--- a/dist/node/types.d.ts
+++ b/dist/node/types.d.ts
@@ -1,6 +1,6 @@
/// <reference types="node" />
/// <reference types="node" />
-import Stream from "node:stream";
+import * as Stream from "node:stream";
import { Response } from "@buttercup/fetch";
export { Request, Response } from "@buttercup/fetch";
export type AuthHeader = string;
10 changes: 10 additions & 0 deletions collect_release_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

mkdir -p release/
for f in packages/**/**/package.tgz; do
package="$(echo "${f}" | cut -b 11- | rev | cut -b 13- | rev)"
cp "${f}" "release/$(echo ${package} | sed 's/\//-/').tgz"
done

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@
"preact": "patch:preact@npm:10.10.0#.yarn/patches/preact-npm-10.10.0-dd04de05e8.patch",
"start-server-and-test": "patch:start-server-and-test@npm:1.14.0#.yarn/patches/start-server-and-test-npm-1.14.0-841aa34fdf.patch",
"stylelint-config-rational-order": "patch:stylelint-config-rational-order@npm%3A0.1.2#./.yarn/patches/stylelint-config-rational-order-npm-0.1.2-d8336e84ed.patch",
"uuid@^8.3.2": "patch:uuid@npm:8.3.2#.yarn/patches/uuid-npm-8.3.2-eca0baba53.patch"
"uuid@^8.3.2": "patch:uuid@npm:8.3.2#.yarn/patches/uuid-npm-8.3.2-eca0baba53.patch",
"webdav@^5.2.2": "patch:webdav@npm%3A5.2.2#./.yarn/patches/webdav-npm-5.2.2-791e72c3de.patch"
},
"volta": {
"node": "18.17.0",
"yarn": "3.6.1"
}
}
Loading