Skip to content

Commit

Permalink
build(test): changed config
Browse files Browse the repository at this point in the history
  • Loading branch information
m62624 committed Aug 18, 2023
1 parent cfff05f commit 498c9fe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
48 changes: 19 additions & 29 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ on:

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

# Шаг для входа в 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: Build Image (dependencies)
run: |
docker pull ${{ env.IMAGE_DOCKER }}; \
docker buildx build --push -t ${{ env.IMAGE_DOCKER }} --cache-to type=inline --cache-from type=registry,ref=${{ env.IMAGE_DOCKER }} .
docker pull ${{ env.IMAGE_DOCKER }} && \
docker build -t ${{ env.IMAGE_DOCKER }} . \
&& docker push ${{ env.IMAGE_DOCKER }}
# Job для проверки кода линтером
linter-check-all-versions:
needs: build-image
Expand All @@ -48,80 +48,71 @@ jobs:
needs: linter-check-all-versions
runs-on: ubuntu-latest
steps:
# Шаг для клонирования репозитория
- name: Checkout code
uses: actions/checkout@v3
# Шаг для входа в 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 -v "$(pwd):/main_project" ${{ env.IMAGE_DOCKER }} \
cargo test --manifest-path ./flexible_inspect_rs/Cargo.toml
docker run ${{ env.IMAGE_DOCKER }} sh -c \
"ls -a; cargo test --manifest-path ./flexible_inspect_rs/Cargo.toml"
docs-rust-tests:
needs: linter-check-all-versions
runs-on: ubuntu-latest
steps:
# Шаг для клонирования репозитория
- name: Checkout code
uses: actions/checkout@v3
# Шаг для входа в 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 -v "$(pwd):/main_project" ${{ env.IMAGE_DOCKER }} \
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:
# Шаг для клонирования репозитория
- name: Checkout code
uses: actions/checkout@v3
# Шаг для входа в 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 -v "$(pwd):/main_project" --security-opt seccomp=unconfined ${{ env.IMAGE_DOCKER }} \
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: ./coverage/cobertura-report
path: cobertura.xml

# Шаг для отправки отчета о покрытии в Codecov
- name: Send coverage report to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/cobertura-report
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 -v "$(pwd):/main_project" ${{ env.IMAGE_DOCKER }} wasm-pack test --node flexible_inspect_js
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
Expand All @@ -131,7 +122,7 @@ jobs:
run: echo ${{ secrets.PAT_GITHUB }} | docker login ghcr.io -u ${{ secrets.NAME_LOGIN }} --password-stdin
- name: Build packages (npm)
run: |
docker run -v "$(pwd):/main_project" ${{ env.IMAGE_DOCKER }} \
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
Expand Down Expand Up @@ -183,7 +174,6 @@ jobs:
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
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ LABEL org.opencontainers.image.source="https://github.com/m62624/flexible_inspec
LABEL description="Docker image for building the project"

# Copy project
COPY . .
CMD ["echo","Welcome to the project build :D"]
Empty file added aboba_test
Empty file.

0 comments on commit 498c9fe

Please sign in to comment.