Skip to content

Commit

Permalink
Merge pull request #175 from r-lib/feature/linux-rpm-distros
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored Aug 27, 2023
2 parents edc019e + bc411d8 commit 2c421c7
Show file tree
Hide file tree
Showing 70 changed files with 6,869 additions and 370 deletions.
185 changes: 153 additions & 32 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,130 @@ name: Test

on:
workflow_dispatch:
inputs:
inplinuxx8664:
description: |
Build on Linux x86_64
required: false
type: choice
options:
- 'yes'
- 'no'
default: 'yes'
inplinuxaarch64:
description: |
Build Linux aarch64
required: false
type: choice
options:
- 'yes'
- 'no'
default: 'no'
inpmacos:
description: |
Build macOS
required: false
type: choice
options:
- 'yes'
- 'no'
default: 'yes'
inpwindows:
description: |
Build Windows
required: false
type: choice
options:
- 'yes'
- 'no'
default: 'yes'
push:
branches: [ 'dev', 'main' ]
pull_request:
branches: [main, master]
branches: [main, master, dev]
schedule:
- cron: '30 6 * * *'

env:
RUST_BACKTRACE: 1

jobs:

linux:
linux-build-x86_64:
if: ${{ github.event.inputs.inplinuxx8664 == '' || github.event.inputs.inplinuxx8664 == 'yes' }}
runs-on: ubuntu-latest
name: Linux
env:
RUST_BACKTRACE: 1
name: Linux build x86_64

steps:

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 10

- name: Build rig
run: |
docker build -t rig:latest .
docker run --name quickrig rig:latest ls out
docker cp quickrig:out .
ls out
cp out/rig* .
make linux-in-docker
- name: Upload build as artifact
uses: actions/upload-artifact@v3
if: success()
with:
name: rig-linux
name: rig-linux-x86_64
path: 'rig-*.tar.gz'

- name: Install rig
run: |
sudo tar xzf rig-*.tar.gz -C /usr/local
linux-tests-x86_64-setup:
needs: linux-build-x86_64
runs-on: ubuntu-latest
name: Linux test setup x86_64
outputs:
containers: ${{ steps.matrix-setup-x86_64.outputs.containers }}

- name: Install bats
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up matrix of containers
id: matrix-setup-x86_64
run: |
sudo apt-get update && sudo apt-get install bats
containers=$(make print-linux-variants-json)
echo "containers=$containers" >> $GITHUB_OUTPUT
- name: Run tests
linux-tests-x86_64:
needs: linux-tests-x86_64-setup
strategy:
fail-fast: false
matrix:
container: ${{ fromJson(needs.linux-tests-x86_64-setup.outputs.containers) }}
runs-on: ubuntu-latest
name: ${{ matrix.container }} (x86_64)

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download build from artifacts
uses: actions/download-artifact@v3
with:
name: rig-linux-x86_64

- name: Uncompress rig build
run: |
bats tests/test-linux.sh
mkdir build
tar xzf rig-*.tar.gz -C build
find build
linux-arm:
- name: Test
run: |
make linux-test-${{ matrix.container }}
if ls tests/results | grep -q fail; then
echo Some tests failed;
exit 1;
fi
linux-build-aarch64:
if: ${{ github.event.inputs.inplinuxaarch64 == 'yes' }}
runs-on: [linux-arm64]
name: Linux-aaarch
name: Linux build aaarch
env:
RUST_BACKTRACE: 1

Expand All @@ -67,13 +139,7 @@ jobs:

- name: Build rig
run: |
docker system prune -f
docker build -t rig:latest .
docker rm quickrig 2>/dev/null || true
docker run --name quickrig rig:latest ls out
docker cp quickrig:out .
ls out
cp out/rig* .
make linux-in-docker
- name: Upload build as artifact
uses: actions/upload-artifact@v3
Expand All @@ -82,9 +148,65 @@ jobs:
name: rig-linux-aarch64
path: 'rig-*.tar.gz'

# TODO: run tests in Docker container
linux-tests-aarch64-setup:
needs: linux-build-aarch64
runs-on: ubuntu-latest
name: Linux test setup aarch64
outputs:
containers: ${{ steps.matrix-setup-aarch64.outputs.containers }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up matrix of containers
id: matrix-setup-aarch64
run: |
containers=$(make print-linux-variants-json)
echo "containers=$containers" >> $GITHUB_OUTPUT
linux-tests-aarch64:
needs: linux-tests-aarch64-setup
strategy:
fail-fast: false
matrix:
container: ${{ fromJson(needs.linux-tests-aarch64-setup.outputs.containers) }}
runs-on: ubuntu-latest
name: ${{ matrix.container }} (aarch64)

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Checkout
uses: actions/checkout@v3

- name: Download build from artifacts
uses: actions/download-artifact@v3
with:
name: rig-linux-aarch64

- name: Uncompress rig build
run: |
mkdir build
tar xzf rig-*.tar.gz -C build
find build
- name: Test
run: |
make linux-test-${{ matrix.container }}
if ls tests/results | grep -q fail; then
echo Some tests failed;
exit 1;
fi
env:
DOCKER_DEFAULT_PLATFORM: "linux/arm64"

macos:
if: ${{ github.event.inputs.inpmacos == '' || github.event.inputs.inpmacos == 'yes' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }}
env:
Expand Down Expand Up @@ -127,6 +249,7 @@ jobs:
bats tests/test-macos.sh
windows:
if: ${{ github.event.inputs.inpwindows == '' || github.event.inputs.inpwindows == 'yes' }}
runs-on: windows-latest
name: Windows
env:
Expand All @@ -140,9 +263,7 @@ jobs:
fetch-depth: 10

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
uses: dtolnay/rust-toolchain@stable

- name: Install make
run: choco install make
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ _rim.ps1
/Rig.app/build-x86_64
/Rig.app/lib
/releases
/tests/results
/build
/rig-*.tar.gz
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

FROM alpine:3.15

COPY . rig

RUN apk add curl
RUN apk add curl bash

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rust.sh && sh rust.sh -y

Expand All @@ -30,10 +28,10 @@ RUN cd openssl-* && \
rm -rf /usr/local/bin/openssl \
/usr/local/share/{man/doc}

# build rig ---------------------------------------------------------------
RUN mkdir /work

RUN source $HOME/.cargo/env && cd rig && make linux
WORKDIR /work

RUN mkdir out && cp rig/rig-*.tar.gz out
RUN apk add file

RUN ls -l out
ENV PATH="/root/.cargo/bin:$PATH"
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ linux: export DEP_OPENSSL_INCLUDE = /usr/local/include/
linux: rig-$(VERSION).tar.gz

rig-$(VERSION).tar.gz: target/release/rig
ls -l target/release/rig
strip -x target/release/rig
mkdir -p build/bin
mkdir -p build/share/bash-completion/completions
Expand All @@ -54,6 +55,54 @@ rig-$(VERSION).tar.gz: target/release/rig
mkdir -p build/share/rig
curl -L -o build/share/rig/cacert.pem 'https://curl.se/ca/cacert.pem'
tar cz -C build -f $@ bin share
if [[ -n "$$LOCAL_UID" && -n "$$LOCAL_GID" ]]; then \
chown -R "$$LOCAL_UID":"$$LOCAL_GID" build target $@; \
fi

shell-linux:
docker compose build
docker run -ti -v .:/work rlib/rig-builder:latest bash

VARIANTS = ubuntu-20.04 ubuntu-22.04 debian-11 debian-12 centos-7 rockylinux-8 rockylinux-9 opensuse/leap-15.3 opensuse/leap-15.4 fedora-37 fedora-38 almalinux-8 almalinux-9
print-linux-variants:
@echo $(VARIANTS)
print-linux-variants-json:
@echo $(VARIANTS) | sed 's/ /","/g' | sed 's/^/["/' | sed 's/$$/"]/'

linux-in-docker:
docker compose build
docker run -v .:/work \
-e LOCAL_UID=`id -u` -e LOCAL_GID=`id -g` \
rlib/rig-builder:latest make linux

ifeq "$(DOCKER_DEFAULT_PLATFORM)" ""
DOCKER_ARCH :=
else
DOCKER_ARCH := --platform=$(DOCKER_DEFAULT_PLATFORM)
endif

define GEN_TESTS
linux-test-$(variant):
mkdir -p tests/results
rm -f tests/results/`echo $(variant) | tr / -`.fail \
tests/results/`echo $(variant) | tr / -`.success
docker run -t --rm $(DOCKER_ARCH) --privileged \
-v $(PWD):/work `echo $(variant) | tr - :` \
bash -c /work/tests/test-linux-docker.sh && \
touch tests/results/`echo $(variant) | tr / -`.success || \
touch tests/results/`echo $(variant) | tr / -`.fail
shell-$(variant):
docker run -ti --rm -v $(PWD):/work `echo $(variant) | tr - :` bash
TEST_IMAGES += linux-test-$(variant)
endef
$(foreach variant, $(VARIANTS), $(eval $(GEN_TESTS)))

linux-test-all: $(TEST_IMAGES)
if ls tests/results | grep -q fail; then \
echo Some tests failed; \
ls tests/results; \
exit 1; \
fi

# -------------------------------------------------------------------------

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

services:
rig:
image: "rlib/rig-builder:latest"
build:
context: .
dockerfile: Dockerfile
command: sleep 100000d
volumes:
- type: bind
source: .
target: /work
Loading

0 comments on commit 2c421c7

Please sign in to comment.