Upload binaries on end of CI #207
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
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
name: Linux | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Install dependencies | |
run: | | |
# 2.3.6-0.1build1 is hack workaround for Microsoft unixodbc-dev being installed, which has no static files! | |
sudo apt-get update | |
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y --allow-downgrades --no-install-recommends unixodbc-dev=2.3.6-0.1build1 libodbc1=2.3.6-0.1build1 odbcinst1debian2=2.3.6-0.1build1 odbcinst=2.3.6-0.1build1 odbc-postgresql libsqliteodbc | |
sudo pg_ctlcluster 14 main start || true | |
sudo pg_lsclusters | |
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- uses: Swatinem/rust-cache@v2 | |
- name: Check formatting | |
run: cargo fmt -- --check | |
- name: Clippy | |
run: cargo clippy | |
- name: Build and test | |
env: | |
ODBC_SYS_STATIC_PATH: /usr/lib/x86_64-linux-gnu/ | |
POSTGRES_DRIVER: /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so | |
SQLITE_DRIVER: /usr/lib/x86_64-linux-gnu/odbc/libsqlite3odbc.so | |
POSTGRES_SERVER: localhost | |
POSTGRES_PORT: 5432 | |
POSTGRES_USERNAME: postgres | |
POSTGRES_PASSWORD: postgres | |
RUST_BACKTRACE: 1 | |
run: cargo test -- --nocapture | |
docker: | |
runs-on: ubuntu-20.04 | |
needs: [build_and_test] | |
strategy: | |
matrix: | |
include: | |
- build_platform: linux/amd64 | |
build_host: x86_64-unknown-linux-musl | |
build_arch: amd64 | |
- build_platform: linux/arm64 | |
build_host: aarch64-unknown-linux-musl | |
build_arch: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
/tmp/.buildx-cache | |
key: | |
buildx-${{ matrix.build_host }}-${{hashFiles('Dockerfile')}} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: ${{ matrix.build_platform }} | |
- name: Setup Qemu | |
if: ${{ matrix.build_arch != 'amd64'}} | |
run: | | |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
- name: Docker build | |
run: | | |
docker buildx build --platform ${{ matrix.build_platform }} --build-arg HOST=${{ matrix.build_host }} --tag wait_for_db:latest --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache,mode=max --output=type=docker . | |
- name: Docker help test | |
run: | | |
docker run --platform ${{ matrix.build_platform }} --name wait_for_db wait_for_db --help | |
- name: Docker copy | |
run: | | |
docker cp wait_for_db:/wait_for_db wait-for-db-linux-${{ matrix.build_arch }} | |
- name: ldd check | |
if: ${{ matrix.build_arch == 'amd64'}} | |
run: | | |
ldd wait-for-db-linux-${{ matrix.build_arch }} | grep "statically linked" | |
retVal=$? | |
if [ $retVal -ne 0 ]; then | |
ldd wait-for-db-linux-${{ matrix.build_arch }} | |
echo Found local non-static refs! | |
exit 1 | |
fi | |
- name: Archive binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wait-for-db-linux-${{ matrix.build_arch }} | |
path: wait-for-db-linux-${{ matrix.build_arch }} |