wip action #3978
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: [push, pull_request, workflow_dispatch] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
ubuntu_test: | |
strategy: | |
fail-fast: true | |
runs-on: ubuntu-latest | |
steps: | |
# Clone project | |
- uses: actions/checkout@v3 | |
# Install buildx | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
# Set buildx cache | |
- name: Cache register | |
uses: actions/cache@v3 | |
with: | |
path: ~/buildx-cache | |
key: buildx-cache | |
# Install cargo make | |
- uses: davidB/rust-cargo-make@v1 | |
# Cache Rust | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ hashFiles('./Cargo.lock') }} | |
# Prepare CI with images containers and permissions | |
- name: Prepare CI | |
run: | | |
wget https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img | |
mv ubuntu-22.04-minimal-cloudimg-amd64.img tests/ubuntu-22.04-minimal-cloudimg-amd64.img | |
mkdir -p $HOME/.nanocl_dev/state/vms/images | |
mkdir -p $HOME/.nanocl_dev/state/proxy/sites-enabled | |
mkdir -p $HOME/.nanocl_dev/state/proxy/sites-available | |
sudo sh -c "echo '\n127.0.0.1 store.nanocl.internal\n127.0.0.1 nanocl.internal' >> /etc/hosts" | |
docker pull cockroachdb/cockroach:v23.1.13 | |
docker pull ghcr.io/next-hat/metrsd:0.5.0 | |
docker pull ghcr.io/next-hat/nanocl-dev:dev | |
docker pull ghcr.io/next-hat/nanocl-qemu:8.0.2.0 | |
docker pull ghcr.io/next-hat/nanocl-get-started:latest | |
docker buildx build --load --cache-from type=local,src=~/buildx-cache --cache-to type=local,dest=~/buildx-cache -t ndns:dev -f ./bin/ndns/Dockerfile . | |
docker buildx build --load --cache-from type=local,src=~/buildx-cache --cache-to type=local,dest=~/buildx-cache -t nproxy:dev -f ./bin/nproxy/Dockerfile . | |
docker compose -f ./tests/docker-compose.yaml up -d | |
sleep 4 | |
sh scripts/prepare_test_ci.sh | |
sleep 4 | |
docker ps -a | |
sudo chmod -R 777 $HOME/.cargo/registry | |
ls -la $HOME/.nanocl_dev/state | |
ls -la $HOME/.nanocl_dev/state/proxy | |
ls -la /run/nanocl | |
# Run coverage | |
- name: Run tests | |
run: cargo make covgenci | |
# Upload it to codecov | |
- name: Codecov | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV }} | |
files: ./lcov.info | |
flags: unittests # optional | |
# Fix permissions to upload artifacts | |
- name: Fix perms | |
run: | | |
sudo chmod -R 777 target | |
sudo chmod -R 777 $HOME/.cargo/registry |