diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 75b120274..7f39c7be6 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -216,6 +216,74 @@ jobs: path: | ./**/*.log + + test-docker-x64-package: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ inputs.branch }} + - name: Get actual branch + run: | + echo "ACTUAL_BRANCH=$(git rev-parse --abbrev-ref HEAD | tr '/' '-')" | tee -a "${GITHUB_ENV}" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build docker image + run: | + echo "::group::Build docker hurl" + docker_build_date=$(date "+%Y-%m-%d %H-%M-%S") + docker builder prune \ + --all \ + --force + docker build . \ + --file contrib/docker/Dockerfile \ + --build-arg docker_build_date="${docker_build_date}" \ + --build-arg hurl_branch=${ACTUAL_BRANCH} \ + --tag local/hurl + docker inspect local/hurl + docker run --rm local/hurl --version + echo "::endgroup::" + - name: Integration tests + uses: addnab/docker-run-action@v3 + with: + image: local/hurl + options: --volume ${{ github.workspace }}:/work --workdir /work --privileged --env CARGO_TERM_COLOR=always --entrypoint sh + run: | + echo "::group::Install system prerequisistes" + set -e + cat /etc/os-release + apk add sudo bash curl python3 py3-pip + echo "::endgroup::" + echo "::group::Install alpine prerequisistes" + bash bin/install_prerequisites_alpine.sh + echo "::endgroup::" + echo "::group::Install tests prerequisites" + bash bin/install_python3_venv.sh + export PATH=/tmp/hurl-python3-venv/bin:$PATH + which python3 + python3 --version + pip --version + bash bin/test/test_prerequisites.sh + echo "::endgroup::" + echo "::group::Environment" + bash bin/environment.sh + echo "::endgroup::" + echo "::group::Integration tests" + bash bin/test/test_integ.sh + echo "::endgroup::" + - name: find artifacts + run: | + pwd + find . -name "*.log" + - name: Archive production artifacts + uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: test-docker-x64-package-artifacts + path: | + ./**/*.log + package-deb-x64: runs-on: ubuntu-20.04 steps: diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index 39dd15d22..82a845e35 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -1,17 +1,15 @@ FROM alpine:3.17 AS builder -WORKDIR /tmp -ARG hurl_latest_version +WORKDIR /tmp/hurl +COPY . /tmp/hurl # hadolint ignore=DL3018 RUN apk add --no-cache bash git && \ - git clone --quiet --depth 1 --branch ${hurl_latest_version} https://github.com/Orange-OpenSource/hurl.git /tmp/hurl -WORKDIR /tmp/hurl -RUN bash -c bin/install_prerequisites_alpine.sh && \ + bash -c bin/install_prerequisites_alpine.sh && \ bash -c bin/install_rust.sh && \ bash -c ./bin/release/release.sh FROM alpine:3.17 AS runner ARG docker_build_date -ARG hurl_latest_version +ARG hurl_branch LABEL "org.opencontainers.image.source"="https://github.com/Orange-OpenSource/hurl" LABEL "org.opencontainers.image.description"="Hurl is a command line tool that runs HTTP requests defined in a simple plain text format" LABEL "org.opencontainers.image.licenses"="Apache-2.0" @@ -20,7 +18,7 @@ LABEL "com.orange.hurl.authors"="Fabrice REIX, Jean Christophe AMIEL, Orange-Ope LABEL "com.orange.hurl.url"="https://hurl.dev" LABEL "com.orange.hurl.documentation"="https://hurl.dev" LABEL "com.orange.hurl.source"="https://github.com/Orange-OpenSource/hurl" -LABEL "com.orange.hurl.version"=${hurl_latest_version} +LABEL "com.orange.hurl.version"=${hurl_branch} LABEL "com.orange.hurl.vendor"="Orange-OpenSource" LABEL "com.orange.hurl.licenses"="Apache-2.0" LABEL "com.orange.hurl.title"="Hurl" @@ -35,4 +33,3 @@ COPY --from=builder /usr/lib/libxml2.so.2 /usr/lib/ COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/ COPY --from=builder /usr/lib/liblzma.so.5 /usr/lib/ ENTRYPOINT ["/usr/bin/hurl"] - diff --git a/contrib/docker/README.md b/contrib/docker/README.md index 016e90f47..35f3292dc 100644 --- a/contrib/docker/README.md +++ b/contrib/docker/README.md @@ -3,14 +3,20 @@ ``` echo | docker login ghcr.io --username hurl-bot --password-stdin ``` +# Clone desired tag + +``` +git clone --depth 1 https://github.com/Orange-OpenSource/hurl.git --branch /tmp/hurl +``` # Build image ``` -hurl_latest_version=$(curl --silent "https://api.github.com/repos/Orange-OpenSource/hurl/releases/latest" | jq -r .tag_name) +cd /tmp/hurl +tag=$(git rev-parse --abbrev-ref HEAD | tr '/' '-') docker_build_date=$(date "+%Y-%m-%d %H-%M-%S") docker builder prune --all -docker build --build-arg docker_build_date="${docker_build_date}" --build-arg hurl_latest_version=${hurl_latest_version} --tag ghcr.io/orange-opensource/hurl:latest --tag ghcr.io/orange-opensource/hurl:${hurl_latest_version} . +docker build . --file contrib/docker/Dockerfile --build-arg docker_build_date="${docker_build_date}" --build-arg hurl_branch=${tag} --tag ghcr.io/orange-opensource/hurl:latest --tag ghcr.io/orange-opensource/hurl:${tag} ``` # Get docker hurl version @@ -35,6 +41,6 @@ docker run --rm -v /tmp/test.hurl:/tmp/test.hurl ghcr.io/orange-opensource/hurl: # Push to github container registry ``` -docker push ghcr.io/orange-opensource/hurl:${hurl_latest_version} +docker push ghcr.io/orange-opensource/hurl:${tag} docker push ghcr.io/orange-opensource/hurl:latest ```