From 965d7dbb664d1d53c76eb41271969e4c034a8fc6 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Tue, 23 Jan 2024 05:58:12 +0000 Subject: [PATCH] Minimal set of working Gitea workflows. (#138) As a first step on https://git.vdb.to/cerc-io/laconicd/issues/116, provide a minimal set of actions which are either already working or expected to work on Gitea. Reviewed-on: https://git.vdb.to/cerc-io/laconicd/pulls/138 Co-authored-by: Thomas E Lackey Co-committed-by: Thomas E Lackey --- .gitea/workflows/build.yml | 17 +++++ .gitea/workflows/deploy-contract.yml | 20 ++++++ .gitea/workflows/docker-image.yml | 28 ++++++++ .gitea/workflows/goreleaser.yml | 28 ++++++++ .gitea/workflows/lint.yml | 42 ++++++++++++ .gitea/workflows/proto.yml | 28 ++++++++ .gitea/workflows/test.yml | 99 ++++++++++++++++++++++++++++ .github/workflows/lint.yml | 5 +- Makefile | 4 +- scripts/integration-test-all.sh | 2 +- 10 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/deploy-contract.yml create mode 100644 .gitea/workflows/docker-image.yml create mode 100644 .gitea/workflows/goreleaser.yml create mode 100644 .gitea/workflows/lint.yml create mode 100644 .gitea/workflows/proto.yml create mode 100644 .gitea/workflows/test.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 00000000..79b5d544 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,17 @@ +name: Build +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - run: | + make build diff --git a/.gitea/workflows/deploy-contract.yml b/.gitea/workflows/deploy-contract.yml new file mode 100644 index 00000000..1276ed46 --- /dev/null +++ b/.gitea/workflows/deploy-contract.yml @@ -0,0 +1,20 @@ +name: Deploy Contract +on: + pull_request: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - name: Test contract + run: | + make contract-tools + # This seems to be an empty placeholder. + make test-contract diff --git a/.gitea/workflows/docker-image.yml b/.gitea/workflows/docker-image.yml new file mode 100644 index 00000000..0d70cb5a --- /dev/null +++ b/.gitea/workflows/docker-image.yml @@ -0,0 +1,28 @@ +name: Publish on release +on: + release: + types: [published] +jobs: + build: + name: Run docker build and publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run docker build + run: docker build -t cerc-io/laconicd -f Dockerfile . + - name: Get the version + id: vars + run: | + echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) + echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) + - name: Tag docker image + run: docker tag cerc-io/laconicd git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}} + - name: Tag docker image + run: docker tag git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}} git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.tag}} + - name: Docker Login + run: echo ${{ secrets.CICD_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin + - name: Docker Push + run: docker push git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}} + - name: Docker Push TAGGED + run: docker push git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.tag}} + diff --git a/.gitea/workflows/goreleaser.yml b/.gitea/workflows/goreleaser.yml new file mode 100644 index 00000000..75e8650e --- /dev/null +++ b/.gitea/workflows/goreleaser.yml @@ -0,0 +1,28 @@ +name: goreleaser + +on: + push: + tags: + - "v*.*.*" +jobs: + goreleaser: + runs-on: ubuntu-latest + environment: release + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - name: release dry run + run: make release-dry-run + - name: setup release environment + env: + GITHUB_TOKEN: ${{ secrets.CICD_PUBLISH_TOKEN }} + run: |- + echo 'GITHUB_TOKEN=${{secrets.CICD_PUBLISH_TOKEN}}' > .release-env + - name: release publish + run: make release diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml new file mode 100644 index 00000000..d683dced --- /dev/null +++ b/.gitea/workflows/lint.yml @@ -0,0 +1,42 @@ +name: Lint +# Lint runs golangci-lint over the entire ethermint repository This workflow is +# run on every pull request and push to main The `golangci` will pass without +# running if no *.{go, mod, sum} files have been changed. +on: + pull_request: + push: + branches: + - main +jobs: + golangci: + name: Run golangci-lint + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + # Required: setup-go, for all versions v3.0.0+ of golangci-lint + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - uses: actions/checkout@v3 + - uses: golangci/golangci-lint-action@v3.3.1 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: latest + args: --timeout 10m + github-token: ${{ secrets.github_token }} + + python-lint: + # For compatibility with Gitea + env: + USER: root + name: Run flake8 on python integration tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v20 + - uses: cachix/cachix-action@v12 + with: + name: ethermint + - run: | + nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py" diff --git a/.gitea/workflows/proto.yml b/.gitea/workflows/proto.yml new file mode 100644 index 00000000..86175a90 --- /dev/null +++ b/.gitea/workflows/proto.yml @@ -0,0 +1,28 @@ +name: Protobuf +# Protobuf runs buf (https://buf.build/) lint and check-breakage +# This workflow is only run when a .proto file has been changed +on: + pull_request: + paths: + - "proto/**" + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v3 + - uses: bufbuild/buf-setup-action@v1.9.0 + - uses: bufbuild/buf-lint-action@v1 + with: + input: "proto" + + break-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: bufbuild/buf-setup-action@v1.9.0 + - uses: bufbuild/buf-breaking-action@v1 + with: + input: "proto" + against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto" diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 00000000..86b9fbbb --- /dev/null +++ b/.gitea/workflows/test.yml @@ -0,0 +1,99 @@ +name: Tests +on: + pull_request: + push: + branches: + - main + - release/** + +jobs: + test-unit: + # This test case doesn't work in CI, run as root. + env: + SKIP_UNIT_TESTS: TestInitConfigNonNotExistError + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - uses: actions/checkout@v3 + - name: Test + run: | + make test-unit + + test-importer: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - uses: actions/checkout@v3 + - name: test-importer + run: | + make test-import + + test-rpc: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.21 + check-latest: true + - uses: actions/checkout@v3 + - name: Test rpc endpoint + run: | + make test-rpc + + sdk_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Checkout laconic-sdk + uses: actions/checkout@v3 + with: + path: "./laconic-sdk/" + repository: cerc-io/laconic-sdk + fetch-depth: 0 + ref: main + - name: Environment + run: ls -tlh && env + + - name: Build laconicd container + working-directory: tests/sdk_tests + run: ./build-laconicd-container.sh + + - name: Build laconic-sdk container + working-directory: laconic-sdk + run: ./scripts/build-sdk-test-container.sh + + - name: Start containers + working-directory: tests/sdk_tests + run: docker compose up -d + + - name: Run tests + working-directory: tests/sdk_tests + run: ./run-tests.sh + + - name: Start containers (auctions enabled) + working-directory: tests/sdk_tests + env: + TEST_AUCTION_ENABLED: true + run: docker compose up -d + + - name: Run auction tests + working-directory: tests/sdk_tests + run: ./run-tests.sh test:auctions + + - name: Start containers (expiry enabled) + working-directory: tests/sdk_tests + env: + TEST_REGISTRY_EXPIRY: true + run: docker compose up -d + + - name: Run nameservice expiry tests + working-directory: tests/sdk_tests + run: ./run-tests.sh test:nameservice-expiry diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b79a434d..3a839689 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,6 +35,9 @@ jobs: if: env.GIT_DIFF python-lint: + # For compatibility with Gitea + env: + USER: root name: Run flake8 on python integration tests runs-on: ubuntu-latest steps: @@ -49,4 +52,4 @@ jobs: **/**.py - run: | nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py" - if: env.GIT_DIFF \ No newline at end of file + if: env.GIT_DIFF diff --git a/Makefile b/Makefile index 72d7a58b..4d9c77e9 100644 --- a/Makefile +++ b/Makefile @@ -316,7 +316,7 @@ TEST_TARGETS := test-unit test-unit-cover test-race # Test runs-specific rules. To add a new test target, just add # a new rule, customise ARGS or TEST_PACKAGES ad libitum, and # append the new rule to the TEST_TARGETS list. -test-unit: ARGS=-timeout=10m -race -test.v +test-unit: ARGS=-timeout=10m -race -test.v -skip $(SKIP_UNIT_TESTS) test-unit: TEST_PACKAGES=$(PACKAGES_UNIT) test-race: ARGS=-race @@ -334,7 +334,7 @@ else endif test-import: - go test -run TestImporterTestSuite -v --vet=off github.com/cerc-io/laconicd/tests/importer + go test -run TestImporterTestSuite -timeout=20m -v --vet=off github.com/cerc-io/laconicd/tests/importer test-rpc: ./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 2 -m "rpc" -r "true" diff --git a/scripts/integration-test-all.sh b/scripts/integration-test-all.sh index a0523a52..77c72af1 100755 --- a/scripts/integration-test-all.sh +++ b/scripts/integration-test-all.sh @@ -146,7 +146,7 @@ echo "done sleeping" set +e if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then - time_out=300s + time_out=900s if [[ $TEST == "pending" ]]; then time_out=60m0s fi