test cicd #284
Workflow file for this run
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: CICD | |
on: [push, pull_request] | |
env: | |
ARTIFACT_DIR: release-artifacts | |
jobs: | |
check: | |
runs-on: ubuntu-22.04 | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: --entrypoint redis-server | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Init rust envrionment | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- uses: davidB/rust-cargo-make@v1 | |
- name: Cache rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Check format | |
run: cargo fmt --all -- --check | |
# - name: Check clippy | |
# run: cargo clippy --all --all-features | |
# - name: Run rust test | |
# run: cargo test --all-features | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
# this might remove tools that are actually needed, | |
# if set to "true" but frees about 6 GB | |
tool-cache: false | |
# all of these default to true, but feel free to set to | |
# "false" if necessary for your workflow | |
docker-images: false | |
swap-storage: false | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
- name: Setup k8s e2e env | |
uses: AbsaOSS/k3d-action@v2 | |
with: | |
cluster-name: spacegate-test | |
args: >- | |
--agents 1 | |
--no-lb | |
--k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*" | |
- name: Init k8s e2e env | |
run: | | |
bash ./tests/e2e/e2e-test-init.sh | |
- name: Run k8s e2e test | |
run: | | |
cd ./tests/e2e | |
sudo bash ./e2e-test.sh | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v2 | |
with: | |
token: ${{secrets.CODECOV_TOKEN}} | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v2 | |
with: | |
name: code-coverage-report | |
path: cobertura.xml | |
release-linux: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [check] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
[ | |
x86_64-unknown-linux-gnu, | |
x86_64-unknown-linux-musl, | |
aarch64-unknown-linux-gnu, | |
aarch64-unknown-linux-musl, | |
] | |
service: [spacegate-simplify, spacegate-native, spacegate] | |
env: | |
OPENSSL_DIR: /opt/openssl | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Cache rust | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: release ${{ matrix.target }} | |
cache-targets: 'false' | |
- name: Install openssl | |
run: | | |
sudo apt update | |
sudo apt install -y pkg-config openssl libssl-dev | |
- name: Run build ${{ matrix.service }} (${{ matrix.target }}) | |
if: matrix.target == 'x86_64-unknown-linux-musl' | |
run: | | |
docker run --rm -t \ | |
-v $HOME/.cargo/registry/:/root/.cargo/registry \ | |
-v "$(pwd)":/volume \ | |
clux/muslrust:stable \ | |
cargo build --release -p ${{ matrix.service }} --target ${{ matrix.target }} | |
sudo chown -R runner target/x86_64-unknown-linux-musl | |
- name: Init rust environment | |
uses: actions-rs/toolchain@v1 | |
if: matrix.target != 'x86_64-unknown-linux-musl' | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Run build ${{ matrix.service }} (${{ matrix.target }}) | |
uses: actions-rs/cargo@v1 | |
if: matrix.target != 'x86_64-unknown-linux-musl' | |
with: | |
use-cross: true | |
command: build | |
args: --release -F static-openssl --target ${{ matrix.target }} -p ${{ matrix.service }} | |
- name: Prepare artifacts | |
run: | | |
SRC_DIR=target/${{ matrix.target }}/release | |
DEST_DIR=${{ env.ARTIFACT_DIR }} | |
mkdir -p ${DEST_DIR} | |
RELEASE_NAME=${{ matrix.service }}-${{ matrix.target }}-${{ github.ref_name }} | |
CHECKSUM=${RELEASE_NAME}.checksum.txt | |
mv ${SRC_DIR}/${{ matrix.service }} ${RELEASE_NAME} | |
shasum -a 256 ${RELEASE_NAME} > ${CHECKSUM} | |
mv ${RELEASE_NAME} ${DEST_DIR} | |
mv ${CHECKSUM} ${DEST_DIR} | |
ls ${DEST_DIR} | |
- name: Upload artifacts to summary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_DIR }} | |
path: | | |
${{ env.ARTIFACT_DIR }}/ | |
- name: Upload artifacts to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.ARTIFACT_DIR }}/*.* | |
release-macos: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [check] | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [x86_64-apple-darwin, aarch64-apple-darwin] | |
service: [spacegate-simplify, spacegate-native, spacegate] | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Init rust environment | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Install openssl | |
run: | | |
brew install openssl | |
- name: Run build ${{ matrix.service }} (${{ matrix.target }}) | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: true | |
command: build | |
args: --release -F static-openssl --target ${{ matrix.target }} -p ${{ matrix.service }} | |
- name: Prepare artifacts | |
run: | | |
SRC_DIR=target/${{ matrix.target }}/release | |
DEST_DIR=${{ env.ARTIFACT_DIR }} | |
mkdir -p ${DEST_DIR} | |
RELEASE_NAME_FULL=${{ matrix.service }}-${{ matrix.target }}-${{ github.ref_name }} | |
CHECKSUM_FULL=${RELEASE_NAME_FULL}.checksum.txt | |
mv ${SRC_DIR}/${{ matrix.service }} ${RELEASE_NAME_FULL} | |
shasum -a 256 ${RELEASE_NAME_FULL} > ${CHECKSUM_FULL} | |
mv ${RELEASE_NAME_FULL} ${DEST_DIR} | |
mv ${CHECKSUM_FULL} ${DEST_DIR} | |
ls ${DEST_DIR} | |
- name: Upload artifacts to summary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_DIR }} | |
path: | | |
${{ env.ARTIFACT_DIR }}/ | |
- name: Upload artifacts to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.ARTIFACT_DIR }}/*.* | |
release-windows: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [check] | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
target: [ | |
#TODO openssl error | |
#x86_64-pc-windows-gnu, | |
x86_64-pc-windows-msvc, | |
] | |
service: [spacegate-simplify, spacegate-native, spacegate] | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Init rust environment | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
# - name: Prepare build | |
# shell: bash | |
# run: | | |
# git clone https://github.com/Microsoft/vcpkg --depth=1 | |
# cd vcpkg | |
# bootstrap-vcpkg.bat | |
# vcpkg.exe integrate install | |
# vcpkg.exe install openssl:x64-windows-static | |
# export OPENSSL_NO_VENDOR=1 | |
# export OPENSSL_DIR=$PWD/packages/openssl_x64-windows-static | |
- run: vcpkg install openssl:x64-windows-static-md | |
- name: Run build ${{ matrix.service }} (${{ matrix.target }}) | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release -F static-openssl --target ${{ matrix.target }} -p ${{ matrix.service }} | |
- name: Prepare artifacts | |
shell: bash | |
run: | | |
SRC_DIR=target/${{ matrix.target }}/release | |
DEST_DIR=${{ env.ARTIFACT_DIR }} | |
mkdir -p ${DEST_DIR} | |
RELEASE_NAME_FULL=${{ matrix.service }}-${{ matrix.target }}-${{ github.ref_name }}.exe | |
CHECKSUM_FULL=${RELEASE_NAME_FULL}.checksum.txt | |
mv ${SRC_DIR}/${{ matrix.service }} ${RELEASE_NAME_FULL} | |
certutil -hashfile ${RELEASE_NAME_FULL} SHA256 >${CHECKSUM_FULL} | |
mv ${RELEASE_NAME_FULL} ${DEST_DIR} | |
mv ${CHECKSUM_FULL} ${DEST_DIR} | |
ls ${DEST_DIR} | |
- name: Upload artifacts to summary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_DIR }} | |
path: | | |
${{ env.ARTIFACT_DIR }}/ | |
- name: Upload artifacts to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.ARTIFACT_DIR }}/*.* | |
release-docker: | |
needs: [check] | |
runs-on: ubuntu-latest | |
name: Release docker image to registry | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Init rust envrionment | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Cache rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Build rust | |
run: cargo build --release -p spacegate | |
- name: Copy binary to workspace | |
run: cp ./target/release/spacegate ./services/full/res/ | |
- name: Build and push Docker image to dockerhub | |
uses: mr-smithers-excellent/docker-build-push@v5 | |
with: | |
directory: services/full/res/ | |
dockerfile: services/full/res/Dockerfile | |
registry: docker.io | |
image: ecfront/spacegate | |
tags: ${{ github.ref_name }} | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
push-docker: | |
needs: [check] | |
runs-on: ubuntu-latest | |
name: Push docker image to registry | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Init rust envrionment | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Cache rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Build rust | |
run: cargo build --release -p spacegate | |
- name: Copy binary to workspace | |
run: cp ./target/release/spacegate ./services/full/res/ | |
- name: Build and push Docker image to dockerhub | |
uses: mr-smithers-excellent/docker-build-push@v5 | |
with: | |
directory: services/full/res/ | |
dockerfile: services/full/res/Dockerfile | |
registry: docker.io | |
image: ecfront/spacegate | |
tags: latest | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
publish-lib-kernel: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [check] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Init rust envrionment | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Cargo login | |
run: cargo login ${{ secrets.CRATES_TOKEN }} | |
- name: Cargo package kernel | |
working-directory: kernel | |
run: cargo package | |
- name: Cargo publish kernel | |
working-directory: kernel | |
run: cargo publish |