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

Share a gitlab-ci configuration of client-go #669

Open
Smityz opened this issue Jan 16, 2023 · 0 comments
Open

Share a gitlab-ci configuration of client-go #669

Smityz opened this issue Jan 16, 2023 · 0 comments

Comments

@Smityz
Copy link
Contributor

Smityz commented Jan 16, 2023

Hi everyone, I wrote a configuration for tikv client testing, if someone needs it to run testw in their own gitlab, they can use it directly by saving the codes below as .gitlab-ci.yml at the root path of the project

variables:
  TIKV_VERSION: v5.3.0

stages:
  - Download Dependency
  - Unit Test
  - Integration Test

dependency:
  stage: Download Dependency
  image: golang:1.19
  variables:
    GOPATH: ${CI_PROJECT_DIR}/.go
    TIUP_HOME: ${CI_PROJECT_DIR}/tiup
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - tiup/
      - .go/pkg/mod/
    policy: push
  script:
    - curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh && tiup/bin/tiup install tikv:${TIKV_VERSION} pd:${TIKV_VERSION} grafana:${TIKV_VERSION} prometheus:${TIKV_VERSION} playground
    # set up deploy token, so we can access private repo
    - echo -e "machine ${GIT_URL}\nlogin gitlab-deploy-token\npassword ${DEPLOY_TOKEN}"  > ~/.netrc
    - go mod download
    - cd integration_tests && go mod download

golangci-lint:
  stage: Unit Test
  image: golangci/golangci-lint:v1.47.3
  variables:
    GOPATH: ${CI_PROJECT_DIR}/.go
  script:
    - golangci-lint run -v
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - .go/pkg/mod/
    policy: pull

.unit_test_env: &unit_test_env
  image: golang:1.19
  variables:
    GOPATH: ${CI_PROJECT_DIR}/.go
    TIUP_HOME: ${CI_PROJECT_DIR}/tiup
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - .go/pkg/mod/
    policy: pull

test:
  stage: Unit Test
  <<: *unit_test_env
  script:
    - go test ./...

race-test:
  stage: Unit Test
  <<: *unit_test_env
  script:
    - go test -race ./...

.integration_test_env: &integration_test_env
  image: golang:1.19
  variables:
    GOPATH: ${CI_PROJECT_DIR}/.go
    TIUP_HOME: ${CI_PROJECT_DIR}/tiup
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - tiup/
      - .go/pkg/mod/
    policy: pull

.start_integration_test: &start_integration_test
  - ./tiup/bin/tiup playground --mode tikv-slim ${TIKV_VERSION} --kv.config integration_tests/raw/tikv-${TIKV_API_VERSION}.toml &
  - sleep 20
  - cd integration_tests/raw &&  if [ "$ENABLE_RACE" = "true" ]; then go test --with-tikv ./... -race; else go test --with-tikv ./...; fi

integration-local-v1-ttl:
  stage: Integration Test
  before_script:
    - export TIKV_API_VERSION="v1ttl"
  <<: *integration_test_env
  script:
    - *start_integration_test

integration-local-v2:
  stage: Integration Test
  before_script:
    - export TIKV_API_VERSION="v2"
  <<: *integration_test_env
  script:
    - *start_integration_test

integration-local-race-v1-ttl:
  stage: Integration Test
  before_script:
    - export TIKV_API_VERSION="v1ttl"
    - export ENABLE_RACE="true"
  <<: *integration_test_env
  script:
    - *start_integration_test

integration-local-race:
  stage: Integration Test
  before_script:
    - export TIKV_API_VERSION="v2"
    - export ENABLE_RACE="true"
  <<: *integration_test_env
  script:
    - cd integration_tests/raw && go test --with-tikv ./... -race
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant