# .gitlab-ci.yml # # ink # # pipelines can be triggered manually in the web stages: - check - workspace - examples - publish variables: GIT_STRATEGY: fetch GIT_DEPTH: 100 CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}" CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}" CI_SERVER_NAME: "GitLab CI" REGISTRY: registry.parity.io/parity/infrastructure/scripts ALL_CRATES: "core alloc prelude primitives lang lang/macro" .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 image: ${REGISTRY}/ink-ci-linux:latest before_script: - cargo -vV - rustc -vV - rustup show - bash --version # if there is no directory for this $CI_COMMIT_REF_NAME/$CI_JOB_NAME # create such directory and # create hardlinks recursively of all the files from the master/$CI_JOB_NAME if it exists - if [[ ! -d $CARGO_TARGET_DIR ]]; then mkdir -p /ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}; cp -al /ci-cache/${CI_PROJECT_NAME}/targets/${CI_DEFAULT_BRANCH}/${CI_JOB_NAME} /ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME} || echo "_____No such target dir, proceeding from scratch_____"; fi - sccache -s only: - master - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - schedules - web - branches dependencies: [] interruptible: true retry: max: 2 when: - runner_system_failure - unknown_failure - api_failure tags: - linux-docker #### stage: check check-std: stage: check <<: *docker-env script: - for crate in ${ALL_CRATES}; do cargo check --verbose --all-features --manifest-path ${crate}/Cargo.toml; done check-wasm: stage: check <<: *docker-env script: - for crate in ${ALL_CRATES}; do cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml; done #### stage: workspace build-std: stage: workspace <<: *docker-env needs: - check-std script: - for crate in ${ALL_CRATES}; do cargo build --verbose --all-features --release --manifest-path ${crate}/Cargo.toml; done build-wasm: stage: workspace <<: *docker-env needs: - check-wasm script: - for crate in ${ALL_CRATES}; do cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path ${crate}/Cargo.toml; done test: stage: workspace <<: *docker-env needs: - check-std script: - cargo test --verbose --all-features --no-fail-fast --release --workspace codecov: stage: workspace <<: *docker-env needs: - check-std variables: # According to https://github.com/mozilla/grcov/blob/master/README.md # we have to use these variables. CARGO_INCREMENTAL: 0 # If `-Zno-landing-pads` is enabled some some tests start to fail. RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off" # The `cargo-taurpalin` coverage reporting tool seems to have better code instrumentation # and thus produces better results for Rust codebases in general. However, unlike `grcov` it # requires running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` # instead. script: # RUSTFLAGS are the cause target cache can't be used here - unset "CARGO_TARGET_DIR" - cargo clean - cargo test --verbose --all-features --no-fail-fast --workspace - cargo build --verbose --all-features --workspace - grcov ./target -s . -t coveralls+ --guess-directory-when-missing --llvm --branch --ignore-not-existing --ignore "/*" --token "$CODECOV_TOKEN" --commit-sha "$CI_COMMIT_SHA" --output-file ccov.json # We'd like to not use a remote bash script for uploading the coverage reports, # however this job seems to be more tricky than we hoped. - bash <(curl -s https://codecov.io/bash) -t "$CODECOV_TOKEN" -X gcov -f ccov.json clippy-std: stage: workspace <<: *docker-env needs: - check-std script: - for crate in ${ALL_CRATES}; do cargo clippy --verbose --all-features --manifest-path ${crate}/Cargo.toml -- -D warnings; done clippy-wasm: stage: workspace <<: *docker-env needs: - check-wasm script: - for crate in ${ALL_CRATES}; do cargo clippy --verbose --no-default-features --manifest-path ${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings; done fmt: stage: workspace <<: *docker-env script: - cargo fmt --verbose --all -- --check #### stage: examples .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 cargo-contract || echo $? - cargo contract -V examples-test: stage: examples <<: *docker-env script: - for example in examples/*/; do cargo test --verbose --manifest-path ${example}/Cargo.toml; done examples-fmt: stage: examples <<: *docker-env script: - for example in examples/*/; do cargo fmt --verbose --manifest-path ${example}/Cargo.toml -- --check; done examples-clippy-std: stage: examples <<: *docker-env script: - for example in examples/*/; do cargo clippy --verbose --manifest-path ${example}/Cargo.toml -- -D warnings; done examples-clippy-wasm: stage: examples <<: *docker-env script: - for example in examples/*/; do cargo clippy --verbose --manifest-path ${example}/Cargo.toml --no-default-features --target wasm32-unknown-unknown -- -D warnings; done examples-contract-build: stage: examples <<: *docker-env script: - *update-cargo-contract - for example in examples/*/; do pushd $example && cargo contract build && popd; done examples-generate-metadata: stage: examples <<: *docker-env script: - *update-cargo-contract - for example in examples/*/; do pushd $example && cargo contract generate-metadata && popd; done #### stage: publish publish-docs: stage: publish <<: *docker-env variables: GIT_DEPTH: 0 only: - master - schedules - tags script: - rm -rf /tmp/* - unset CARGO_TARGET_DIR # Set git config - rm .git/config - git config user.email "devops-team@parity.io" - git config user.name "${GITHUB_USER}" - git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git" - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" - git fetch origin gh-pages # Generating Docs - time cargo doc --no-deps --all-features -p type-metadata -p ink_abi -p ink_abi_derive -p ink_core -p ink_core_derive -p ink_primitives -p ink_prelude -p ink_lang -p ink_lang_macro # saving README and docs - mv target/doc/ /tmp/ - cp README.md /tmp/doc/ - git checkout gh-pages - mv _config.yml /tmp/doc/ # remove everything and restore generated docs, README and Jekyll config - rm -rf ./* - mv /tmp/doc/* . # Upload files - git add --all --force - git status - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME} and pushed to gh-pages" - git push origin gh-pages --force after_script: - rm -rf .git/ ./*