From 5bfccdad3c3f7cd768992e63e6f7fcc4298a9e64 Mon Sep 17 00:00:00 2001 From: tobi Date: Sun, 27 Apr 2025 11:22:35 +0000 Subject: [PATCH] [chore] add woodpecker ci/cd pipelines (#4061) Removes our now unused drone stuff and adds pipelines for our new woodpecker instance. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4061 Co-authored-by: tobi Co-committed-by: tobi --- .drone.yml | 223 --------------------------------- .woodpecker/pr.yaml | 98 +++++++++++++++ .woodpecker/release.yaml | 41 ++++++ .woodpecker/snapshot.yaml | 47 +++++++ docs/api/swagger.yaml | 2 +- internal/media/manager_test.go | 2 +- 6 files changed, 188 insertions(+), 225 deletions(-) delete mode 100644 .drone.yml create mode 100644 .woodpecker/pr.yaml create mode 100644 .woodpecker/release.yaml create mode 100644 .woodpecker/snapshot.yaml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 87038bdd2..000000000 --- a/.drone.yml +++ /dev/null @@ -1,223 +0,0 @@ ---- -### Drone configuration file for GoToSocial. -### Connects to https://drone.superseriousbusiness.org to perform testing, linting, and automatic builds/pushes to docker. -### -### For documentation on drone, see: https://docs.drone.io/ -### For documentation on drone docker pipelines in particular: https://docs.drone.io/pipeline/docker/overview/ -kind: pipeline -type: docker -name: default - -steps: - # We use golangci-lint for linting. - # See: https://golangci-lint.run/ - - name: lint - image: golangci/golangci-lint:v1.62.0 - volumes: - - name: go-build-cache - path: /root/.cache/go-build - - name: golangci-lint-cache - path: /root/.cache/golangci-lint - - name: go-src - path: /go - commands: - - golangci-lint run - when: - event: - include: - - pull_request - - - name: test - image: golang:1.23-alpine - volumes: - - name: go-build-cache - path: /root/.cache/go-build - - name: go-src - path: /go - - name: wazero-compilation-cache - path: /root/.cache/wazero - environment: - CGO_ENABLED: "0" - GTS_WAZERO_COMPILATION_CACHE: "/root/.cache/wazero" - commands: - - apk update --no-cache && apk add git - - >- - go test - -failfast - -timeout=20m - -tags "netgo osusergo static_build kvformat timetzdata" - ./... - - ./test/envparsing.sh - - ./test/swagger.sh - depends_on: - - lint - when: - event: - include: - - pull_request - - - name: web-setup - image: node:18-alpine - volumes: - - name: yarn_cache - path: /tmp/cache - commands: - - yarn --cwd ./web/source install --frozen-lockfile --cache-folder /tmp/cache - - yarn --cwd ./web/source ts-patch install # https://typia.io/docs/setup/#manual-setup - depends_on: - - test - when: - event: - include: - - pull_request - - - name: web-lint - image: node:18-alpine - commands: - - yarn --cwd ./web/source lint - depends_on: - - web-setup - when: - event: - include: - - pull_request - - - name: web-build - image: node:18-alpine - commands: - - yarn --cwd ./web/source build - depends_on: - - web-setup - when: - event: - include: - - pull_request - - - name: snapshot - image: superseriousbusiness/gotosocial-drone-build:0.8.0 # https://github.com/superseriousbusiness/gotosocial-drone-build - volumes: - - name: go-build-cache - path: /root/.cache/go-build - - name: docker - path: /var/run/docker.sock - environment: - DOCKER_USERNAME: gotosocial - DOCKER_PASSWORD: - from_secret: gts_docker_password - S3_ACCESS_KEY_ID: - from_secret: gts_s3_access_key_id - S3_SECRET_ACCESS_KEY: - from_secret: gts_s3_secret_access_key - S3_HOSTNAME: "https://s3.superseriousbusiness.org" - S3_BUCKET_NAME: "gotosocial-snapshots" - commands: - # Create a snapshot build with GoReleaser. - - git fetch --tags - - goreleaser release --clean --snapshot - - # Login to Docker, push Docker image snapshots + manifests. - - /go/dockerlogin.sh - - docker push superseriousbusiness/gotosocial:snapshot-arm64v8 - - docker push superseriousbusiness/gotosocial:snapshot-amd64 - - | - docker manifest create superseriousbusiness/gotosocial:snapshot \ - superseriousbusiness/gotosocial:snapshot-amd64 \ - superseriousbusiness/gotosocial:snapshot-arm64v8 - - docker manifest push superseriousbusiness/gotosocial:snapshot - - # Publish binary .tar.gz snapshots to S3. - - /go/snapshot_publish.sh - when: - event: - include: - - push - branch: - include: - - main - - - name: release - image: superseriousbusiness/gotosocial-drone-build:0.8.0 # https://github.com/superseriousbusiness/gotosocial-drone-build - volumes: - - name: go-build-cache - path: /root/.cache/go-build - - name: docker - path: /var/run/docker.sock - environment: - DOCKER_USERNAME: gotosocial - DOCKER_PASSWORD: - from_secret: gts_docker_password - GITHUB_TOKEN: - from_secret: github_token - commands: - - git fetch --tags - - /go/dockerlogin.sh - - # When releasing, compare commits to the most recent tag that is not the - # current one AND is not a release candidate tag (ie., no "rc" in the name). - # - # The DRONE_TAG env var should point to the tag that triggered this build. - # See: https://docs.drone.io/pipeline/environment/reference/drone-tag/ - # - # Note, this may cause annoyances when doing backport releases, for example, - # releasing v0.10.1 when we've already released v0.15.0 or whatever, but - # they should only be superficial annoyances related to the release notes. - - GORELEASER_PREVIOUS_TAG=$(git tag -l | grep -v "rc\|${DRONE_TAG}" | sort -V -r | head -n 1) goreleaser release --clean - when: - event: - include: - - tag - -# We can speed up builds significantly by caching build artifacts between runs. -# See: https://docs.drone.io/pipeline/docker/syntax/volumes/host/ -volumes: - - name: go-build-cache - host: - path: /drone/gotosocial/go-build - - name: golangci-lint-cache - host: - path: /drone/gotosocial/golangci-lint - - name: go-src - host: - path: /drone/gotosocial/go - - name: docker - host: - path: /var/run/docker.sock - -trigger: - repo: - - superseriousbusiness/gotosocial - - NyaaaWhatsUpDoc/gotosocial - - f0x52/gotosocial - ---- -kind: pipeline -type: docker -name: cron - -trigger: - event: - - cron - cron: - - nightly - -clone: - disable: true - -steps: - - name: mirror - image: superseriousbusiness/gotosocial-drone-build:0.8.0 - environment: - ORIGIN_REPO: https://github.com/superseriousbusiness/gotosocial - TARGET_REPO: https://codeberg.org/superseriousbusiness/gotosocial - CODEBERG_USER: gotosocialbot - CODEBERG_EMAIL: admin@gotosocial.org - CODEBERG_TOKEN: - from_secret: gts_codeberg_token - commands: - - /go/codeberg_clone.sh - ---- -kind: signature -hmac: 64ce0d466c7a48b6aa24a8836cfad7eae71faeae0b2e5342beb6428233a65eee - -... diff --git a/.woodpecker/pr.yaml b/.woodpecker/pr.yaml new file mode 100644 index 000000000..18b96708d --- /dev/null +++ b/.woodpecker/pr.yaml @@ -0,0 +1,98 @@ +# https://woodpecker-ci.org/docs/usage/workflow-syntax#when---global-workflow-conditions +when: + - event: pull_request + +steps: + # Lint the Go code. + lint: + # We use golangci-lint for linting. + # See: https://golangci-lint.run/ + image: golangci/golangci-lint:v1.62.0 + pull: true + + # https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user + backend_options: + docker: + user: 1000:1000 + + # https://woodpecker-ci.org/docs/usage/volumes + volumes: + - /woodpecker/gotosocial/go-build-cache:/.cache/go-build + - /woodpecker/gotosocial/go-pkg-cache:/go/pkg + - /woodpecker/gotosocial/golangci-lint-cache:/.cache/golangci-lint + + # https://woodpecker-ci.org/docs/usage/environment + environment: + GOFLAGS: "-buildvcs=false" + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#commands + commands: + - golangci-lint run + + # Test the Go code. + test: + image: golang:1.23-alpine + pull: true + + # https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user + backend_options: + docker: + user: 1000:1000 + + # https://woodpecker-ci.org/docs/usage/volumes + volumes: + - /woodpecker/gotosocial/go-build-cache:/.cache/go-build + - /woodpecker/gotosocial/go-pkg-cache:/go/pkg + - /woodpecker/gotosocial/wazero-compilation-cache:/.cache/wazero + - /woodpecker/gotosocial/test-tmp:/tmp + + # https://woodpecker-ci.org/docs/usage/environment + environment: + CGO_ENABLED: "0" + GTS_WAZERO_COMPILATION_CACHE: "/.cache/wazero" + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#commands + commands: + - >- + go test + -ldflags="-s -w -extldflags '-static'" + -tags="netgo osusergo static_build kvformat timetzdata" + -failfast + -timeout=30m + ./... + - ./test/envparsing.sh + - ./test/swagger.sh + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on + depends_on: [lint] + + # Validate the web code. + web: + image: node:lts-alpine + pull: true + + # https://woodpecker-ci.org/docs/administration/configuration/backends/docker#run-user + backend_options: + docker: + user: 1000:1000 + + # https://woodpecker-ci.org/docs/usage/volumes + volumes: + - /woodpecker/gotosocial/node_modules:/woodpecker/src/codeberg.org/superseriousbusiness/gotosocial/web/source/node_modules + - /woodpecker/gotosocial/yarn-cache:/.cache/yarn + - /woodpecker/gotosocial/web-dist-test:/woodpecker/src/codeberg.org/superseriousbusiness/gotosocial/web/assets/dist + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#commands + commands: + # Install web dependencies. + - yarn --cwd ./web/source install --frozen-lockfile --cache-folder /.cache/yarn + - yarn --cwd ./web/source ts-patch install # https://typia.io/docs/setup/#manual-setup + + # Lint web source. + - yarn --cwd ./web/source lint + + # Ensure build works. + - yarn --cwd ./web/source build + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#depends_on + depends_on: [test] diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml new file mode 100644 index 000000000..8a2e2c3d7 --- /dev/null +++ b/.woodpecker/release.yaml @@ -0,0 +1,41 @@ +# https://woodpecker-ci.org/docs/usage/workflow-syntax#when---global-workflow-conditions +when: + - event: push + branch: main + +steps: + release: + # https://github.com/superseriousbusiness/gotosocial-drone-build + image: superseriousbusiness/gotosocial-drone-build:0.8.0 + pull: true + + # https://woodpecker-ci.org/docs/usage/volumes + volumes: + - /woodpecker/gotosocial/go-build-cache-root:/root/.cache/go-build + - /woodpecker/gotosocial/go-pkg-cache-root:/go/pkg + - /var/run/docker.sock:/var/run/docker.sock + + # https://woodpecker-ci.org/docs/usage/environment + # https://woodpecker-ci.org/docs/usage/secrets#usage + environment: + DOCKER_USERNAME: gotosocial + DOCKER_PASSWORD: + from_secret: gts_docker_password + GITHUB_TOKEN: + from_secret: github_token + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#commands + commands: + - git fetch --tags + - /go/dockerlogin.sh + + # When releasing, compare commits to the most recent tag that is not the + # current one AND is not a release candidate tag (ie., no "rc" in the name). + # + # The DRONE_TAG env var should point to the tag that triggered this build. + # See: https://docs.drone.io/pipeline/environment/reference/drone-tag/ + # + # Note, this may cause annoyances when doing backport releases, for example, + # releasing v0.10.1 when we've already released v0.15.0 or whatever, but + # they should only be superficial annoyances related to the release notes. + - GORELEASER_PREVIOUS_TAG=$(git tag -l | grep -v "rc\|${DRONE_TAG}" | sort -V -r | head -n 1) goreleaser release --clean diff --git a/.woodpecker/snapshot.yaml b/.woodpecker/snapshot.yaml new file mode 100644 index 000000000..b268f0ce2 --- /dev/null +++ b/.woodpecker/snapshot.yaml @@ -0,0 +1,47 @@ +# https://woodpecker-ci.org/docs/usage/workflow-syntax#when---global-workflow-conditions +when: + - event: tag + +steps: + snapshot: + # https://github.com/superseriousbusiness/gotosocial-drone-build + image: superseriousbusiness/gotosocial-drone-build:0.8.0 + pull: true + + # https://woodpecker-ci.org/docs/usage/volumes + volumes: + - /woodpecker/gotosocial/go-build-cache-root:/root/.cache/go-build + - /woodpecker/gotosocial/go-pkg-cache-root:/go/pkg + - /var/run/docker.sock:/var/run/docker.sock + + # https://woodpecker-ci.org/docs/usage/environment + # https://woodpecker-ci.org/docs/usage/secrets#usage + environment: + DOCKER_USERNAME: gotosocial + DOCKER_PASSWORD: + from_secret: gts_docker_password + S3_ACCESS_KEY_ID: + from_secret: gts_s3_access_key_id + S3_SECRET_ACCESS_KEY: + from_secret: gts_s3_secret_access_key + S3_HOSTNAME: "https://s3.superseriousbusiness.org" + S3_BUCKET_NAME: "gotosocial-snapshots" + + # https://woodpecker-ci.org/docs/usage/workflow-syntax#commands + commands: + # Create a snapshot build with GoReleaser. + - git fetch --tags + - goreleaser release --clean --snapshot + + # Login to Docker, push Docker image snapshots + manifests. + - /go/dockerlogin.sh + - docker push superseriousbusiness/gotosocial:snapshot-arm64v8 + - docker push superseriousbusiness/gotosocial:snapshot-amd64 + - | + docker manifest create superseriousbusiness/gotosocial:snapshot \ + superseriousbusiness/gotosocial:snapshot-amd64 \ + superseriousbusiness/gotosocial:snapshot-arm64v8 + - docker manifest push superseriousbusiness/gotosocial:snapshot + + # Publish binary .tar.gz snapshots to S3. + - /go/snapshot_publish.sh diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml index cea824694..143329d7f 100644 --- a/docs/api/swagger.yaml +++ b/docs/api/swagger.yaml @@ -1965,7 +1965,7 @@ definitions: x-go-name: Rules source_url: description: The URL for the source code of the software running on this instance, in keeping with AGPL license requirements. - example: https://codeberg.org/superseriousbusiness/gotosocial + example: https://github.com/superseriousbusiness/gotosocial type: string x-go-name: SourceURL terms: diff --git a/internal/media/manager_test.go b/internal/media/manager_test.go index 8497c1c9e..4988c2485 100644 --- a/internal/media/manager_test.go +++ b/internal/media/manager_test.go @@ -859,7 +859,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessWithDiskStorage() { accountID := "01FS1X72SK9ZPW0J1QQ68BD264" - temp := fmt.Sprintf("./%s/gotosocial-test", os.TempDir()) + temp := fmt.Sprintf("%s/gotosocial-test", os.TempDir()) defer os.RemoveAll(temp) disk, err := disk.Open(temp, nil)