Skip to content

Commit

Permalink
Migrate the litmusOcisSpacesDav test from Drone to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vascoguita committed Dec 21, 2022
1 parent 93d9e9e commit 5474aa6
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 164 deletions.
63 changes: 1 addition & 62 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ OC_CI_GOLANG = "owncloudci/golang:1.19"
OC_CI_ALPINE = "owncloudci/alpine:latest"
OSIXIA_OPEN_LDAP = "osixia/openldap:1.3.0"
OC_CI_PHP = "owncloudci/php:7.4"
OC_LITMUS = "owncloud/litmus:latest"
OC_CS3_API_VALIDATOR = "owncloud/cs3api-validator:0.2.0"
OC_CI_BAZEL_BUILDIFIER = "owncloudci/bazel-buildifier:latest"

def makeStep():
return {
"name": "build",
"image": OC_CI_GOLANG,
"commands": [
"make build",
"make build-revad",
],
}

Expand Down Expand Up @@ -69,7 +67,6 @@ def main(ctx):
# implemented for: ocisIntegrationTests and s3ngIntegrationTests
return [
checkStarlark(),
litmusOcisSpacesDav(),
virtualViews(),
] + ocisIntegrationTests(6) + s3ngIntegrationTests(12)

Expand Down Expand Up @@ -132,64 +129,6 @@ def virtualViews():
],
}

def litmusOcisSpacesDav():
return {
"kind": "pipeline",
"type": "docker",
"name": "litmus-owncloud-spaces-dav",
"platform": {
"os": "linux",
"arch": "amd64",
},
"trigger": {
"event": {
"include": [
"pull_request",
"tag",
],
},
},
"steps": [
makeStep(),
{
"name": "revad-services",
"image": OC_CI_GOLANG,
"detach": True,
"commands": [
"cd /drone/src/tests/oc-integration-tests/drone/",
"/drone/src/cmd/revad/revad -c frontend.toml &",
"/drone/src/cmd/revad/revad -c gateway.toml &",
"/drone/src/cmd/revad/revad -c storage-home-ocis.toml &",
"/drone/src/cmd/revad/revad -c storage-users-ocis.toml &",
"/drone/src/cmd/revad/revad -c permissions-ocis-ci.toml &",
"/drone/src/cmd/revad/revad -c users.toml",
],
},
{
"name": "sleep-for-revad-start",
"image": OC_CI_GOLANG,
"commands": [
"sleep 5",
],
},
{
"name": "litmus-owncloud-spaces-dav",
"image": OC_LITMUS,
"environment": {
"LITMUS_USERNAME": "einstein",
"LITMUS_PASSWORD": "relativity",
"TESTS": "basic http copymove props",
},
"commands": [
# The spaceid is randomly generated during the first login so we need this hack to construct the correct url.
"curl -s -k -u einstein:relativity -I http://revad-services:20080/remote.php/dav/files/einstein",
"export LITMUS_URL=http://revad-services:20080/remote.php/dav/spaces/123e4567-e89b-12d3-a456-426655440000!$(ls /drone/src/tmp/reva/data/spaces/personal/)",
"/usr/local/bin/litmus-wrapper",
],
},
],
}

def ocisIntegrationTests(parallelRuns, skipExceptParts = []):
pipelines = []
debugPartsEnabled = (len(skipExceptParts) != 0)
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Docker
on:
workflow_call:
inputs:
file:
required: true
type: string
tag:
type: string
load:
type: boolean
push:
type: boolean

jobs:
docker:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: ${{ inputs.push }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build ${{ (inputs.push && 'and push') || '' }} ${{ inputs.tag }} Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ${{ inputs.file }}
tags: ${{ (inputs.push && format('{0}/', secrets.DOCKERHUB_ORGANIZATION)) || '' }}${{ inputs.tag }}
load: ${{ inputs.load }}
push: ${{ inputs.push }}
- name: Upload ${{ inputs.tag }} Docker image to artifacts
uses: ishworkh/docker-image-artifact-upload@v1
if: ${{ inputs.load }}
with:
image: ${{ inputs.tag }}
retention_days: '1'
38 changes: 15 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,21 @@ jobs:
files: "dist/*"
body_path: "changelog/NOTE.md"
docker:
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
include:
- tag: ${{ secrets.DOCKERHUB_ORGANIZATION }}/reva:${{ github.ref_name }}
file: Dockerfile.reva
- tag: ${{ secrets.DOCKERHUB_ORGANIZATION }}/revad:${{ github.ref_name }}
file: Dockerfile.revad
- tag: ${{ secrets.DOCKERHUB_ORGANIZATION }}/revad:${{ github.ref_name }}-eos
file: Dockerfile.revad-eos
- tag: ${{ secrets.DOCKERHUB_ORGANIZATION }}/revad:${{ github.ref_name }}-ceph
file: Dockerfile.revad-ceph
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push ${{ matrix.tag }}
uses: docker/build-push-action@v3
with:
push: true
file: docker/${{ matrix.file }}
tags: ${{ matrix.tag }}
- image: reva
tag: reva:${{ github.ref_name }}
- image: revad
tag: revad:${{ github.ref_name }}
- image: revad-eos
tag: revad:${{ github.ref_name }}-eos
- image: revad-ceph
tag: revad:${{ github.ref_name }}-ceph
uses: ./.github/workflows/docker.yml
secrets: inherit
with:
file: docker/Dockerfile.${{ matrix.image }}
tag: ${{ matrix.tag }}
push: true
60 changes: 31 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: Test
on: [pull_request, push, workflow_dispatch]

env:
TEST_IMAGE: 'revad:test'

jobs:
test:
integration-test:
runs-on: self-hosted
steps:
- name: Checkout
Expand All @@ -14,50 +11,55 @@ jobs:
uses: actions/setup-go@v3.3.0
with:
go-version-file: go.mod
- name: Test
run: make test
- name: Test integration
run: make test-integration
env:
REDIS_ADDRESS: redis:6379
services:
redis:
image: registry.cern.ch/docker.io/webhippie/redis
docker:
go-test:
runs-on: self-hosted
strategy:
matrix:
image: [reva, revad, revad-eos, revad-ceph]
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image from ${{ matrix.image }}
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile.${{ matrix.image }}
tags: ${{ env.TEST_IMAGE }}
load: ${{ matrix.image == 'revad' }}
- name: Upload ${{ env.TEST_IMAGE }} to artifacts
uses: ishworkh/docker-image-artifact-upload@v1
if: ${{ matrix.image == 'revad' }}
uses: actions/checkout@v3
- name: Setup Go environment
uses: actions/setup-go@v3.3.0
with:
image: ${{ env.TEST_IMAGE }}
retention_days: '1'
go-version-file: go.mod
- name: Test
run: make test
docker:
strategy:
fail-fast: false
matrix:
image: [reva, revad-eos, revad-ceph]
uses: ./.github/workflows/docker.yml
with:
file: docker/Dockerfile.${{ matrix.image }}
docker-revad:
name: docker (revad)
uses: ./.github/workflows/docker.yml
with:
file: docker/Dockerfile.revad
tag: revad:test
load: true
litmus:
needs: docker
needs: docker-revad
runs-on: self-hosted
strategy:
fail-fast: false
matrix:
test: [litmus-1-only, litmus-2-only]
profile: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: ${{ env.TEST_IMAGE }}
image: revad:test
- name: Test
run: make ${{ matrix.test }}
run: make litmus-only
env:
PROFILE: ${{ matrix.profile }}
IMAGE: revad:test
59 changes: 26 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
BUILD_DATE=`date +%FT%T%z`
GIT_COMMIT ?= `git rev-parse --short HEAD`
GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "dirty-"`
VERSION ?= `git describe --always`
GO_VERSION ?= `go version | awk '{print $$3}'`
BUILD_FLAGS="-X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"
BUILD_DATE = `date +%FT%T%z`
GIT_COMMIT ?= `git rev-parse --short HEAD`
GIT_DIRTY = `git diff-index --quiet HEAD -- || echo "dirty-"`
VERSION ?= `git describe --always`
GO_VERSION ?= `go version | awk '{print $$3}'`
BUILD_FLAGS = "-X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"

TEST_IMAGE ?= revad:test
.PHONY: all
all: build-revad build-reva test lint gen-doc

IMAGE ?= revad:test

.PHONY: test-image
test-image:
docker build -t $(TEST_IMAGE) -f docker/Dockerfile.revad .

LITMUS ?= $(CURDIR)/tests/litmus
TIMEOUT ?= 3600
URL_PATH ?= /remote.php/webdav
docker build -t $(IMAGE) -f docker/Dockerfile.revad .

.PHONY: litmus-1-only
litmus-1-only:
@cd $(LITMUS) && URL_PATH=$(URL_PATH) TEST_IMAGE=$(TEST_IMAGE) docker-compose up --remove-orphans --force-recreate --exit-code-from litmus --abort-on-container-exit --timeout $(TIMEOUT)
LITMUS ?= $(CURDIR)/tests/litmus
TIMEOUT ?= 3600

.PHONY: litmus-1
litmus-1: test-image litmus-1-only

.PHONY: litmus-2-only
litmus-2-only: URL_PATH=/remote.php/dav/files/4c510ada-c86b-4815-8820-42cdf82c3d51
litmus-2-only: litmus-1-only
.PHONY: litmus-only
litmus-only:
ifndef PROFILE
$(error PROFILE is not defined)
else
@cd $(LITMUS) && IMAGE=$(IMAGE) docker-compose --profile $(PROFILE) up --remove-orphans --exit-code-from litmus-$(PROFILE) --abort-on-container-exit --timeout $(TIMEOUT)
endif

.PHONY: litmus-2
litmus-2: test-image litmus-2-only
.PHONY: litmus
litmus: test-image litmus-only

TOOLCHAIN ?= $(CURDIR)/toolchain
GOLANGCI_LINT ?= $(TOOLCHAIN)/golangci-lint
Expand All @@ -47,7 +46,7 @@ $(GOLANGCI_LINT):

.PHONY: check-changelog
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
@$(GOLANGCI_LINT) run || (echo "Tip: many lint errors can be automatically fixed with \"make lint-fix\""; exit 1)

.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT)
Expand Down Expand Up @@ -86,9 +85,6 @@ off:
imports: off $(GOIMPORTS)
$(GOIMPORTS) -w tools pkg internal cmd

.PHONY: build
build: build-revad build-reva

.PHONY: build-cephfs
build-cephfs: build-revad-cephfs build-reva

Expand Down Expand Up @@ -123,11 +119,11 @@ build-reva-docker: off

.PHONY: test
test: off
go test -coverprofile coverage.out -race $$(go list ./... | grep -v /tests/integration)
go test -race $$(go list ./... | grep -v /tests/integration)

.PHONY: test-integration
test-integration: build
cd tests/integration && go test -race ./...
test-integration: build-revad
go test -race ./tests/integration/...

.PHONY: contrib
contrib:
Expand All @@ -141,9 +137,6 @@ gen-doc:
clean: toolchain-clean
rm -rf dist

.PHONY: all
all: build test lint gen-doc

# create local build versions
dist: gen-doc
go run tools/create-artifacts/main.go -version ${VERSION} -commit ${GIT_COMMIT} -goversion ${GO_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You need to have [Go](https://golang.org/doc/install) (version 1.16 or higher),
```
$ git clone https://github.com/cs3org/reva
$ cd reva
$ make build
$ make
$ mkdir -p /etc/revad
$ cp examples/storage-references/users.demo.json /etc/revad/users.json
$ cp examples/storage-references/groups.demo.json /etc/revad/groups.json
Expand Down
3 changes: 2 additions & 1 deletion changelog/unreleased/enhancement-litmus.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Enhancement: Migrate the litmus tests from Drone to GitHub Actions

We've migrated the litmusOcisOldWebdav and the litmusOcisNewWebdav tests from Drone to GitHub Actions.
We've migrated the litmusOcisOldWebdav, litmusOcisSpacesDav and the litmusOcisNewWebdav tests from Drone to GitHub Actions.

https://github.com/cs3org/reva/pull/3566
https://github.com/cs3org/reva/pull/3565
Loading

0 comments on commit 5474aa6

Please sign in to comment.