From bd876b4877ea717bf6966b9972203e84ef94b3c6 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 6 Mar 2023 15:37:40 +0100 Subject: [PATCH 1/4] =?UTF-8?q?ci:=20=E2=9C=A8=20Add=20publish=20image=20C?= =?UTF-8?q?I?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker_image.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/docker_image.yml diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml new file mode 100644 index 00000000..073816a1 --- /dev/null +++ b/.github/workflows/docker_image.yml @@ -0,0 +1,39 @@ +--- +name: Publish Docker Image + +on: + push: + branches: + - main + paths: + - ".devcontainer/Dockerfile" + workflow_dispatch: + +jobs: + publish-container: + name: Update container image on DockerHub + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push container + uses: docker/build-push-action@v4 + with: + context: . + file: .devcontainer/Dockerfile + tags: espressif/rust-std-training:latest + push: true + platforms: linux/amd64, linux/arm64 From ef067a1611a98b6fc7302d3387ee7e928e2b9830 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 6 Mar 2023 15:38:06 +0100 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E2=9C=A8=20Update=20CI=20to=20use?= =?UTF-8?q?=20the=20published=20image=20if=20no=20chnages=20on=20the=20Doc?= =?UTF-8?q?kerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/{dockerimage.yml => CI.yml} | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) rename .github/workflows/{dockerimage.yml => CI.yml} (64%) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/CI.yml similarity index 64% rename from .github/workflows/dockerimage.yml rename to .github/workflows/CI.yml index 5fd3c5c0..32fb3a48 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/CI.yml @@ -12,9 +12,7 @@ on: - cron: "50 7 * * *" jobs: - # To avoid uploading the Docker image to a registry yet - # the image is built here & immediately used to test all exercises in. - build_image_and_test: + build-examples: name: Build ${{ matrix.project.name }} runs-on: ubuntu-latest strategy: @@ -41,10 +39,21 @@ jobs: - name: Checkout the repository uses: actions/checkout@v3 + - name: Verify Changed files + uses: tj-actions/verify-changed-files@v13 + id: dockerfile-changed + with: + files: .devcontainer/Dockerfile + - name: Build Docker image - run: docker image build --tag esp --file .devcontainer/Dockerfile . + if: steps.dockerfile-changed.outputs.files_changed == 'true' + run: docker image build --tag espressif/rust-std-training --file .devcontainer/Dockerfile . + + - name: Pull Docker image + if: steps.dockerfile-changed.outputs.files_changed == 'false' + run: docker image pull espressif/rust-std-training - name: Test code example in Docker image run: | docker run --mount type=bind,source="$(pwd)",target=/workspace,consistency=cached \ - --rm esp:latest /bin/bash /workspace/.devcontainer/test.sh ${{ matrix.project.path }} + --rm espressif/rust-std-training:latest /bin/bash /workspace/.devcontainer/test.sh ${{ matrix.project.path }} From ae68119c6fd85b072aca22a41bf6e60c0d9f48e1 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 6 Mar 2023 15:38:25 +0100 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E2=AC=86=EF=B8=8F=20Update=20mdboo?= =?UTF-8?q?k=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/book.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml index 8f9ae235..5593d762 100644 --- a/.github/workflows/book.yml +++ b/.github/workflows/book.yml @@ -1,10 +1,9 @@ --- - name: Book CI on: [push, pull_request] env: - MDBOOK_VERSION: "0.4.14" + MDBOOK_VERSION: "0.4.28" jobs: build: From b841026c6658d9b15c316e4e5cf09bde86b3db89 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 6 Mar 2023 15:43:50 +0100 Subject: [PATCH 4/4] =?UTF-8?q?ci:=20=E2=9C=A8=20Build=20all=20the=20examp?= =?UTF-8?q?les=20before=20publishing=20the=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker_image.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/docker_image.yml b/.github/workflows/docker_image.yml index 073816a1..5b7440d5 100644 --- a/.github/workflows/docker_image.yml +++ b/.github/workflows/docker_image.yml @@ -10,8 +10,44 @@ on: workflow_dispatch: jobs: + build-examples: + name: Build ${{ matrix.project.name }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + project: + - name: "button-interrupt" + path: "advanced/button-interrupt" + - name: "i2c-driver" + path: "advanced/i2c-driver" + - name: "i2c-sensor-reading" + path: "advanced/i2c-sensor-reading" + - name: "hardware-check" + path: "intro/hardware-check" + - name: "http-client" + path: "intro/http-client" + - name: "http-server" + path: "intro/http-server" + - name: "mqtt" + path: "intro/mqtt/exercise" + - name: "mqtt - host client" + path: "intro/mqtt/host-client" + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Build Docker image + run: docker image build --tag espressif/rust-std-training --file .devcontainer/Dockerfile . + + - name: Test code example in Docker image + run: | + docker run --mount type=bind,source="$(pwd)",target=/workspace,consistency=cached \ + --rm espressif/rust-std-training:latest /bin/bash /workspace/.devcontainer/test.sh ${{ matrix.project.path }} + publish-container: name: Update container image on DockerHub + needs: build-examples runs-on: ubuntu-latest steps: - name: Checkout