From d57e5a41ca3a28f76b7c210a81663db4e402f003 Mon Sep 17 00:00:00 2001 From: Haydn Vestal Date: Thu, 28 Aug 2025 11:52:06 +0530 Subject: [PATCH 1/6] devcontainer: add Codespaces/Dev Container configuration --- .devcontainer/devcontainer.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c41d4a5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "ha-ndarray", + "image": "mcr.microsoft.com/devcontainers/rust:1-bookworm", + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "remoteUser": "vscode", + "containerEnv": { + "RUST_BACKTRACE": "1" + }, + "postCreateCommand": "rustup component add clippy rustfmt && sudo apt-get update && sudo apt-get install -y ocl-icd-opencl-dev clinfo && cargo fetch", + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml" + ] + } + } +} + From 3cf66c566c9c27423bc93874cc3ab2e05d441219 Mon Sep 17 00:00:00 2001 From: Haydn Vestal Date: Thu, 28 Aug 2025 11:54:49 +0530 Subject: [PATCH 2/6] devcontainer: switch to official rust:1-bookworm base and add Dockerfile; install OpenCL headers --- .devcontainer/Dockerfile | 18 ++++++++++++++++++ .devcontainer/devcontainer.json | 10 ++++------ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..25be0f6 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +FROM rust:1-bookworm + +# Install build and OpenCL headers (compile-time), BLAS/LAPACK, git, curl +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + pkg-config \ + git \ + curl \ + ocl-icd-opencl-dev \ + clinfo \ + libblas-dev \ + liblapack-dev \ + && rm -rf /var/lib/apt/lists/* + +# Set a default workdir used by Dev Containers / Codespaces +WORKDIR /workspaces/ha-ndarray + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c41d4a5..087a6de 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,14 +1,13 @@ { "name": "ha-ndarray", - "image": "mcr.microsoft.com/devcontainers/rust:1-bookworm", - "features": { - "ghcr.io/devcontainers/features/github-cli:1": {} + "build": { + "dockerfile": "Dockerfile" }, - "remoteUser": "vscode", + "remoteUser": "root", "containerEnv": { "RUST_BACKTRACE": "1" }, - "postCreateCommand": "rustup component add clippy rustfmt && sudo apt-get update && sudo apt-get install -y ocl-icd-opencl-dev clinfo && cargo fetch", + "postCreateCommand": "rustup component add clippy rustfmt && cargo fetch", "customizations": { "vscode": { "extensions": [ @@ -18,4 +17,3 @@ } } } - From e868fec7c8f0fdb0c06533d77f075039a94b8f8b Mon Sep 17 00:00:00 2001 From: Haydn Vestal Date: Thu, 28 Aug 2025 12:01:47 +0530 Subject: [PATCH 3/6] ci: build devcontainer image on PRs --- .github/workflows/devcontainer.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/devcontainer.yml diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 0000000..a2b6fa9 --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,19 @@ +name: Dev Container + +on: + pull_request: + push: + branches: [ devcontainer-codespaces ] + +jobs: + build-devcontainer: + name: Build .devcontainer/Dockerfile + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build dev container image + run: | + docker build -f .devcontainer/Dockerfile -t ha-ndarray-devcontainer:ci . + From 0ce204b593ece23aa74d996359acbc443c09cf59 Mon Sep 17 00:00:00 2001 From: Haydn Vestal Date: Thu, 28 Aug 2025 12:03:33 +0530 Subject: [PATCH 4/6] ci(devcontainer): use buildx with GitHub cache (docker/build-push-action) --- .github/workflows/devcontainer.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index a2b6fa9..df3395f 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -13,7 +13,15 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Build dev container image - run: | - docker build -f .devcontainer/Dockerfile -t ha-ndarray-devcontainer:ci . + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build (cache-enabled) + uses: docker/build-push-action@v5 + with: + context: . + file: .devcontainer/Dockerfile + push: false + tags: ha-ndarray-devcontainer:ci + cache-from: type=gha + cache-to: type=gha,mode=max From cdf661082bd14783f4263224994c03062f978faf Mon Sep 17 00:00:00 2001 From: Haydn Vestal Date: Thu, 28 Aug 2025 12:04:51 +0530 Subject: [PATCH 5/6] ci(devcontainer): build for linux/amd64 and linux/arm64 via Buildx + QEMU (cache-enabled) --- .github/workflows/devcontainer.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index df3395f..6fc537d 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -7,12 +7,19 @@ on: jobs: build-devcontainer: - name: Build .devcontainer/Dockerfile + name: Build .devcontainer/Dockerfile (${{ matrix.platform }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: [ linux/amd64, linux/arm64 ] steps: - name: Checkout uses: actions/checkout@v4 + - name: Set up QEMU (emulation for non-native arch) + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -21,7 +28,8 @@ jobs: with: context: . file: .devcontainer/Dockerfile + platforms: ${{ matrix.platform }} push: false - tags: ha-ndarray-devcontainer:ci + load: true cache-from: type=gha cache-to: type=gha,mode=max From cac1de4eb2f8f66f3e1beca2bbbcaa6efe226396 Mon Sep 17 00:00:00 2001 From: Haydn Vestal Date: Thu, 28 Aug 2025 12:07:06 +0530 Subject: [PATCH 6/6] ci(devcontainer): comment PR with per-job results when Dev Container workflow completes --- .github/workflows/notify-devcontainer.yml | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/notify-devcontainer.yml diff --git a/.github/workflows/notify-devcontainer.yml b/.github/workflows/notify-devcontainer.yml new file mode 100644 index 0000000..35103a0 --- /dev/null +++ b/.github/workflows/notify-devcontainer.yml @@ -0,0 +1,52 @@ +name: Notify Devcontainer Status + +on: + workflow_run: + workflows: ["Dev Container"] + types: [completed] + +jobs: + notify: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + actions: read + steps: + - name: Comment PR with results + uses: actions/github-script@v7 + with: + script: | + const run = context.payload.workflow_run; + const { data } = await github.rest.actions.listJobsForWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: run.id, + per_page: 100, + }); + + const lines = (data.jobs || []).map(j => `- ${j.name}: ${j.conclusion}`); + const body = [ + `Dev Container workflow completed: ${run.conclusion}`, + ``, + `Jobs:`, + ...lines, + ``, + `Run: ${run.html_url}`, + ].join('\n'); + + const prs = run.pull_requests || []; + if (prs.length === 0) { + core.info('No associated PRs to notify.'); + return; + } + + for (const pr of prs) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body, + }); + } +