Skip to content

Commit

Permalink
Create dedicated docker image (#59)
Browse files Browse the repository at this point in the history
This makes it possible to test formatting changes using CSharpier. To
test formatting, both Rust and Dotnet must be installed in the same
docker image. This is because `--library` mode runs `cargo metadata`
command, and formatting runs `dotnet-csharpier` command.

Signed-off-by: Kristupas Antanavicius <kristupas.antanavicius@nordsec.com>
  • Loading branch information
arg0d authored Nov 30, 2023
1 parent 7d49e0e commit dc2fac7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 34 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/rust.yml → .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: C#

on:
push:
Expand All @@ -20,14 +20,7 @@ jobs:
submodules: 'true'
- name: Build
run: |
./build.sh
./generate_bindings.sh
- uses: actions/upload-artifact@v3
with:
path: |
dotnet-tests/UniffiCS/gen
target/debug/libuniffi_fixtures.so
target/debug/uniffi-bindgen-cs
cargo build --release --package uniffi-bindgen-cs
binding-unit-tests:
runs-on: ubuntu-latest
Expand All @@ -43,20 +36,19 @@ jobs:
test-bindings:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/sdk:6.0
needs: build
image: ghcr.io/nordsecurity/uniffi-bindgen-cs-test-runner:v0.1.0
steps:

- uses: actions/checkout@v3
with:
submodules: 'true'

- uses: actions/download-artifact@v3

- name: Test
- name: Test bindings
shell: bash
env:
# Github sets HOME to /github/home and breaks dependencies in Docker image..
# https://github.com/actions/runner/issues/863
HOME: /root
run: |
# copy artifacts to root directory
cp -R artifact/* .
chmod +x target/debug/uniffi-bindgen-cs
source ~/.bashrc
./build.sh
./generate_bindings.sh
./test_bindings.sh
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0

LABEL org.opencontainers.image.source=https://github.com/NordSecurity/uniffi-bindgen-cs

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.72

RUN apt-get update && apt-get install -y --no-install-recommends build-essential && apt-get clean

RUN dotnet tool install -g csharpier
RUN echo 'export PATH="$PATH:/root/.dotnet/tools"' >> /root/.bashrc
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
all: build generate test

build:
./docker_build.sh
./build.sh

generate:
./generate_bindings.sh

test:
./docker_test_bindings.sh
./test_bindings.sh
3 changes: 1 addition & 2 deletions docker_build.sh → docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set -euxo pipefail

docker run \
-ti --rm \
--volume $HOME/.cargo/registry:/usr/local/cargo/registry \
--volume $PWD:/mounted_workdir \
--workdir /mounted_workdir \
rust:1.72-bullseye ./build.sh
ghcr.io/nordsecurity/uniffi-bindgen-cs-test-runner:v0.1.0 bash
10 changes: 0 additions & 10 deletions docker_test_bindings.sh

This file was deleted.

0 comments on commit dc2fac7

Please sign in to comment.