.gitlab-ci.yml 6.88 KB
Newer Older
Denis_P's avatar
Denis_P committed
# .gitlab-ci.yml
#
# ink
#
# pipelines can be triggered manually in the web


stages:
  - check
  - workspace
Denis_P's avatar
Denis_P committed
  - examples
Denis_P's avatar
Denis_P committed
  - publish
Denis_P's avatar
Denis_P committed

variables:
  GIT_STRATEGY:                    fetch
Denis_P's avatar
Denis_P committed
  GIT_DEPTH:                       3
Denis_P's avatar
Denis_P committed
  CARGO_HOME:                      "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}"
Denis_P's avatar
Denis_P committed
  CARGO_TARGET_DIR:                "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
Denis_P's avatar
Denis_P committed
  CI_SERVER_NAME:                  "GitLab CI"
Denis_P's avatar
Denis_P committed
  REGISTRY:                        registry.parity.io/parity/infrastructure/scripts
  ALL_CRATES:                      "core alloc prelude primitives lang lang/macro"
Denis_P's avatar
Denis_P committed

.collect-artifacts:                &collect-artifacts
  artifacts:
    name:                          "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
    when:                          on_success
    expire_in:                     7 days
    paths:
      - artifacts/

.docker-env:                       &docker-env
Denis_P's avatar
Denis_P committed
  image:                           ${REGISTRY}/ink-ci-linux:latest
Denis_P's avatar
Denis_P committed
  before_script:
Denis_P's avatar
Denis_P committed
    - cargo -vV
    - rustc -vV
Denis_P's avatar
Denis_P committed
    - rustup show
Denis_P's avatar
Denis_P committed
    - bash --version
Hero Bird's avatar
Hero Bird committed
    - mkdir -p ${CARGO_HOME}; touch ${CARGO_HOME}/config
Denis_P's avatar
Denis_P committed
    - mkdir -p ${CARGO_TARGET_DIR}
Denis_P's avatar
Denis_P committed
    # global RUSTFLAGS overrides the linker args so this way is better to pass the flags
    - printf '[build]\nrustflags = ["-C", "link-dead-code"]\n' | tee ${CARGO_HOME}/config
Denis_P's avatar
Denis_P committed
    - sccache -s
  only:
    - master
    - /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
    - schedules
    - web
    - /^[0-9]+$/                   # PRs
  dependencies:                    []
  interruptible:                   true
  retry:
    max: 2
    when:
      - runner_system_failure
      - unknown_failure
      - api_failure
Denis_P's avatar
Denis_P committed
  tags:
    - linux-docker


#### stage:                        check
Denis_P's avatar
Denis_P committed

Hero Bird's avatar
Hero Bird committed
check-std:
  stage:                           check
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
    - for crate in ${ALL_CRATES}; do
        cargo check --verbose --all-features --manifest-path ${crate}/Cargo.toml;
Hero Bird's avatar
Hero Bird committed
      done
Denis_P's avatar
Denis_P committed

Hero Bird's avatar
Hero Bird committed
check-wasm:
  stage:                           check
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  script:
Hero Bird's avatar
Hero Bird committed
        cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
      done
Denis_P's avatar
Denis_P committed

#### stage:                        workspace

Hero Bird's avatar
Hero Bird committed
build-std:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  needs:
    - check-std
Denis_P's avatar
Denis_P committed
  script:
Hero Bird's avatar
Hero Bird committed
    - for crate in ${ALL_CRATES}; do
        cargo build --verbose --all-features --release --manifest-path ${crate}/Cargo.toml;
Hero Bird's avatar
Hero Bird committed
      done
Denis_P's avatar
Denis_P committed

Hero Bird's avatar
Hero Bird committed
build-wasm:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  needs:
    - check-wasm
Denis_P's avatar
Denis_P committed
  script:
Hero Bird's avatar
Hero Bird committed
        cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml;
      done
Denis_P's avatar
Denis_P committed

test:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  needs:
    - check-std
Denis_P's avatar
Denis_P committed
  script:
Hero Bird's avatar
Hero Bird committed
    - for crate in ${ALL_CRATES}; do
        cargo test --verbose --all-features --release --manifest-path ${crate}/Cargo.toml;
Hero Bird's avatar
Hero Bird committed
      done
Denis_P's avatar
Denis_P committed

Hero Bird's avatar
Hero Bird committed
clippy-std:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  needs:
    - check-std
Denis_P's avatar
Denis_P committed
  script:
Hero Bird's avatar
Hero Bird committed
    - for crate in ${ALL_CRATES}; do
        cargo clippy --verbose --all-features --manifest-path ${crate}/Cargo.toml -- -D warnings;
Hero Bird's avatar
Hero Bird committed
      done
Denis_P's avatar
Denis_P committed

Hero Bird's avatar
Hero Bird committed
clippy-wasm:
  stage:                           workspace
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  needs:
    - check-wasm
Denis_P's avatar
Denis_P committed
  script:
        cargo clippy --verbose --no-default-features --manifest-path ${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
      done

fmt:
  stage:                           workspace
Hero Bird's avatar
Hero Bird committed
  <<:                              *docker-env
  script:
    - cargo fmt --verbose --all -- --check
Denis_P's avatar
Denis_P committed

Denis_P's avatar
Denis_P committed
#### stage:                        examples
Denis_P's avatar
Denis_P committed

.update-cargo-contract:            &update-cargo-contract
  # `cargo install` returns an error if there is nothing to update, so have to supress it here temporarily
  - cargo install --git https://github.com/paritytech/cargo-contract || echo $?
  - cargo contract -V

Hero Bird's avatar
Hero Bird committed
examples-test:
Denis_P's avatar
Denis_P committed
  stage:                           examples
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  script:
    - for example in examples/*/; do
        cargo test --verbose --manifest-path ${example}/Cargo.toml;
Denis_P's avatar
Denis_P committed
      done

Hero Bird's avatar
Hero Bird committed
examples-fmt:
Denis_P's avatar
Denis_P committed
  stage:                           examples
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  script:
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
        cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check;
Denis_P's avatar
Denis_P committed
      done

Hero Bird's avatar
Hero Bird committed
examples-clippy-std:
Denis_P's avatar
Denis_P committed
  stage:                           examples
Denis_P's avatar
Denis_P committed
  <<:                              *docker-env
  script:
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml -- -D warnings;
Hero Bird's avatar
Hero Bird committed
      done

examples-clippy-wasm:
  stage:                           examples
  <<:                              *docker-env
  script:
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
        cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings;
Hero Bird's avatar
Hero Bird committed
      done

examples-contract-build:
  stage:                           examples
  <<:                              *docker-env
  script:
    - *update-cargo-contract
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
        pushd $example &&
        cargo contract build &&
        popd;
      done

examples-generate-metadata:
Hero Bird's avatar
Hero Bird committed
  stage:                           examples
  <<:                              *docker-env
  script:
    - *update-cargo-contract
    - for example in examples/*/; do
Hero Bird's avatar
Hero Bird committed
        pushd $example &&
        cargo contract generate-metadata &&
Hero Bird's avatar
Hero Bird committed
        popd;
Denis_P's avatar
Denis_P committed
      done
Denis_P's avatar
Denis_P committed

#### stage:                        publish

publish-docs:
  stage:                           publish
  <<:                              *docker-env
Denis_P's avatar
Denis_P committed
  variables:
    GIT_DEPTH:                     0
Denis_P's avatar
Denis_P committed
  only:
    - master
    - schedules
    - tags
  script:
Denis_P's avatar
Denis_P committed
    - rm -rf /tmp/*
    - unset CARGO_TARGET_DIR
Denis_P's avatar
Denis_P committed
    # Set github
    - git config --global user.email "devops-team@parity.io"
    - git config --global user.name "${GITHUB_USER}"
    - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git"
    # Generating Docs
Denis_P's avatar
Denis_P committed
    - time cargo doc --release --no-deps --all --verbose
    # saving README and docs
    - mv target/doc/ /tmp/
    - cp README.md /tmp/doc/
    # on gh-pages branch the contents of target/doc should be in root dir
Denis_P's avatar
Denis_P committed
    - git checkout -b gh-pages || git checkout gh-pages
Denis_P's avatar
Denis_P committed
    - mv _config.yml /tmp/doc/
    # remove everything and restore generated docs, README and Jekyll config
    - rm -vrf ./*
    - mv /tmp/doc/* .
Denis_P's avatar
Denis_P committed
    # Upload files
Denis_P's avatar
Denis_P committed
    - git add --all --force
    - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME} and pushed to gh-pages"
Denis_P's avatar
Denis_P committed
    - git push origin gh-pages --force