Skip to content

build(test): changed config #90

build(test): changed config

build(test): changed config #90

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
branches:
- "*"
env:
IMAGE_DOCKER: ghcr.io/${{ secrets.NAME_LOGIN }}/flexible_inspect:latest
jobs:
# job для сборки образа (в нем будет происходит сборка и тестирование библиотеки)
build-image:
# needs: clone
runs-on: ubuntu-latest
steps:
# Шаг для входа в Docker Registry
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
# Шаг для клонирования репозитория
- name: Checkout code
uses: actions/checkout@v3
# Шаг для сборки и пуша образа (используем кэш прошлой сборки)
- name: Build Image (dependencies)
run: |
docker pull ${{ env.IMAGE_DOCKER }}; \
docker build -t ${{ env.IMAGE_DOCKER }} . \
&& docker push ${{ env.IMAGE_DOCKER }}
# Job для проверки кода линтером
linter-check-all-versions:
needs: build-image
runs-on: ubuntu-latest
steps:
# Шаг для клонирования репозитория
- name: Checkout code
uses: actions/checkout@v3
# Шаг для запуска линтера
- name: Linter check (clippy)
run: cargo clippy -- -D warnings
core_rust-tests:
needs: linter-check-all-versions
runs-on: ubuntu-latest
steps:
# Шаг для входа в Docker Registry
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
# Шаг для запуска контейнера с тестами
- name: Core tests (rust)
run: |
docker run ${{ env.IMAGE_DOCKER }} \
cargo test --manifest-path ./flexible_inspect_rs/Cargo.toml
docs-rust-tests:
needs: linter-check-all-versions
runs-on: ubuntu-latest
steps:
# Шаг для входа в Docker Registry
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
# Шаг для запуска контейнера с тестами
- name: Core tests (rust)
run: |
docker run ${{ env.IMAGE_DOCKER }} \
cargo test --doc --manifest-path ./flexible_inspect_rs/Cargo.toml
# Job для тестирования кода
coverage-tests:
needs: [core_rust-tests, docs-rust-tests]
runs-on: ubuntu-latest
steps:
# Шаг для входа в Docker Registry
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
# Шаг для запуска контейнера с тестами
- name: Coverage tests (tarpaulin)
run: |
FLEX_VALIDATOR_LOG=TRACE docker run --security-opt seccomp=unconfined ${{ env.IMAGE_DOCKER }} \
cargo tarpaulin \
--workspace \
--exclude flexible_inspect_js \
--features export_to_other_languages,serde \
--engine llvm --out xml --output-dir ./coverage/
# Шаг для копирования отчета о покрытии из контейнера
- name: Copy coverage report from container
run: |
docker cp $(docker ps -lq):/main_project/coverage/cobertura.xml .
# Шаг для загрузки отчета о покрытии в Codecov
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: cobertura-report
path: cobertura.xml
# Шаг для отправки отчета о покрытии в Codecov
- name: Send coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: cobertura.xml
only-wasm-tests:
needs: linter-check-all-versions
runs-on: ubuntu-latest
steps:
# Шаг для входа в Docker Registry
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
- name: Wasm tests (JavaScript vesrion)
run: |
docker run ${{ env.IMAGE_DOCKER }} wasm-pack test --node flexible_inspect_js
packages-js:
needs: [core_rust-tests, only-wasm-tests]
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
- name: Build packages (npm)
run: |
docker run ${{ env.IMAGE_DOCKER }} \
wasm-pack build --target nodejs ./flexible_inspect_js; \
docker cp $(docker ps -lq):/main_project/flexible_inspect_js/pkg .; \
- name: Save package to artifacts
uses: actions/upload-artifact@v3
with:
name: javascirpt-npm-${{ github.run_id }}
path: pkg
packages-py:
needs: coverage-tests
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
- name: Build packages (wheel)
run: |
docker run ${{ env.IMAGE_DOCKER }} make dist-python
docker cp $(docker ps -lq):/main_project/dist .
- name: Save package to artifacts
uses: actions/upload-artifact@v3
with:
name: python-wheels-${{ github.run_id }}
path: dist
package-publishing-all-versions:
needs: [packages-js, packages-py]
runs-on: ubuntu-latest
steps:
- name: Log in to `GitHub Docker Registry`
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
- name: Publish packages (crate)
run: |
docker run ${{ env.IMAGE_DOCKER }} cargo publish --token ${{ secrets.CRATESIO_TOKEN }} --manifest-path ./flexible_inspect_rs/Cargo.toml
- name: Download packages (wheels)
uses: actions/download-artifact@v3
with:
name: python-wheels-${{ github.run_id }}
path: dist
- name: Publish packages (wheels)
run: |
docker run -v "$(pwd):/main_project" ${{ env.IMAGE_DOCKER }} twine upload --verbose dist/* --username __token__ --password ${{ secrets.PYPI_TOKEN }}
- name: Download packages (wasm)
uses: actions/download-artifact@v3
with:
name: javascirpt-npm-${{ github.run_id }}
path: pkg
- name: Publish packages (wasm)
run: |
echo //registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}} > ./pkg/.npmrc; \
wasm-pack publish -t nodejs
create-release-on-github:
needs: package-publishing-all-versions
runs-on: ubuntu-latest
steps:
- name: Download packages (wheels)
uses: actions/download-artifact@v3
with:
name: python-wheels-${{ github.run_id }}
path: dist
- name: Download packages (wasm)
uses: actions/download-artifact@v3
with:
name: javascirpt-npm-${{ github.run_id }}
path: pkg
- name: Compress pkg folder (wasm->tgz)
run: tar czf pkg.tgz -C pkg .
- name: Checkout code
uses: actions/checkout@v3
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}-README.md
# note you'll typically need to create a personal access token
# with permissions to create releases in the other repo
token: ${{ secrets.PAT_GITHUB }}
#== release metadata ==
draft: true
files: |
pkg.tgz
dist/*
#=====================