From a407b3fcd9bab6a96bb8d530a806dcbad252b27c Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 26 Aug 2025 00:07:25 +0000 Subject: [PATCH 1/3] feat: Add devcontainer feature and update setup script for CVMFS --- .github/workflows/publish-feature.yml | 34 +++++++++++++++++++++++ README.devcontainer-feature.md | 39 +++++++++++++++++++++++++++ README.md | 17 ++++++++++++ devcontainer-feature.json | 24 +++++++++++++++++ setup-cvmfs.sh | 9 ++++++- 5 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-feature.yml create mode 100644 README.devcontainer-feature.md create mode 100644 devcontainer-feature.json diff --git a/.github/workflows/publish-feature.yml b/.github/workflows/publish-feature.yml new file mode 100644 index 0000000..8ac73c0 --- /dev/null +++ b/.github/workflows/publish-feature.yml @@ -0,0 +1,34 @@ +name: Publish Devcontainer Feature + +on: + release: + types: [created] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Install Devcontainer CLI + run: npm install -g @devcontainers/cli + + - name: Login to GitHub Container Registry + run: echo "${{ secrets.WRITE_PACKAGES_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Add version to environment + run: | + VERSION="${{ github.ref_name }}" + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Add version to devcontainer-feature.json + run: | + jq --arg VERSION "${{ env.VERSION }}" '.version = $VERSION' src/cvmfs/devcontainer-feature.json > tmp.json + mv tmp.json src/cvmfs/devcontainer-feature.json + + - name: Publish Devcontainer Feature + run: devcontainer features publish --namespace ${{ github.actor }}/${{ github.repository }} . + + - name: Build Devcontainer Feature + run: devcontainer build --workspace-folder . --image-name test-cvmfs-feature --additional-features ghcr.io/${{ github.actor }}/${{ github.repository }}/cvmfs:${{ env.VERSION }} diff --git a/README.devcontainer-feature.md b/README.devcontainer-feature.md new file mode 100644 index 0000000..8e85087 --- /dev/null +++ b/README.devcontainer-feature.md @@ -0,0 +1,39 @@ +# CVMFS Devcontainer Feature + +This directory contains a devcontainer feature for installing and configuring the CVMFS client. The definition is located in the top-level directory to allow reuse of the GitHub Actions scripts. + +## Publishing to GHCR + +This feature is intended to be published to the GitHub Container Registry (GHCR) to be easily reusable by other projects. + +### Manual Publishing + +1. **Install the Devcontainer CLI:** + ```bash + npm install -g @devcontainers/cli + ``` + +2. **Create a Personal Access Token (PAT):** + * Go to GitHub **Settings** > **Developer settings** > **Personal access tokens** > **Tokens (classic)**. + * Generate a new token with the `write:packages` scope. + * Export the token as an environment variable: + ```bash + export WRITE_PACKAGES_TOKEN=your-personal-access-token + ``` + +3. **Log in to GHCR:** + ```bash + echo $WRITE_PACKAGES_TOKEN | docker login ghcr.io -u your-github-username --password-stdin + ``` + +4. **Publish the Feature:** + Run the following command from the root of this repository. The namespace should match the GitHub organization (`cvmfs-contrib`). + ```bash + devcontainer features publish src/cvmfs --namespace cvmfs-contrib/ + ``` + +### Automated Publishing + +This repository is configured with a GitHub Actions workflow to automate this process. When a new release is published on GitHub, the workflow will automatically build and publish the feature to GHCR. + +For this to work, the `WRITE_PACKAGES_TOKEN` secret (a Personal Access Token with `write:packages` scope) must be configured in the repository's **Settings > Secrets and variables > Actions**. diff --git a/README.md b/README.md index c2c5fad..03a2d17 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,23 @@ This GitHub Action is only expected to work in workflows that [run on](https://d `windows` targets are not supported. +## Devcontainer Usage + +This repository provide a Dev Container Feature to enable CernVM-FS in your Dev Containers. To use it, open this repository in a devcontainer-compatible editor like VS Code with the Dev Containers extension. + +For example, you can add the following to your `devcontainer.json` to use this feature: +```json +{ + "name": "CVMFS Action Dev", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "ghcr.io/cvmfs-contrib/features/cvmfs": { + "CVMFS_REPOSITORIES": "sft.cern.ch" + } + } +} +``` + ## Use With Docker In case your workflow uses docker containers, the cvmfs directory can be mounted inside the container by using the flag `-v /cvmfs:/cvmfs:shared`. diff --git a/devcontainer-feature.json b/devcontainer-feature.json new file mode 100644 index 0000000..db6b477 --- /dev/null +++ b/devcontainer-feature.json @@ -0,0 +1,24 @@ +{ + "name": "CVMFS", + "id": "cvmfs", + "version": "0.0.0", + "description": "Installs CVMFS client", + "options": { + "CVMFS_REPOSITORIES": { + "type": "string", + "default": "sft.cern.ch", + "description": "Comma-separated list of fully qualified repository names that shall be mountable under /cvmfs" + }, + "CVMFS_CONFIG_PACKAGE": { + "type": "string", + "default": "cvmfs-config-default", + "description": "URL to the cvmfs config package to install" + }, + "CVMFS_HTTP_PROXY": { + "type": "string", + "default": "DIRECT", + "description": "Chain of HTTP proxy groups used by CernVM-FS. Defaults to DIRECT)" + } + }, + "entrypoint": "install-cvmfs-linux.sh" +} diff --git a/setup-cvmfs.sh b/setup-cvmfs.sh index 8389158..67c1e50 100755 --- a/setup-cvmfs.sh +++ b/setup-cvmfs.sh @@ -77,7 +77,14 @@ fi echo "::endgroup::" -if [ "$(uname)" == "Darwin" ]; then +if [ "$(uname)" == "Linux" ]; then + # Mount CVMFS repositories (in case no autofs) + for repo in $(echo ${CVMFS_REPOSITORIES} | sed "s/,/ /g") + do + sudo mount -t cvmfs ${repo} /cvmfs/${repo} + done +elif [ "$(uname)" == "Darwin" ]; then + # Mount CVMFS repositories (no autofs available) for repo in $(echo ${CVMFS_REPOSITORIES} | sed "s/,/ /g") do mkdir -p /Users/Shared/cvmfs/${repo} From 266001933f12f9e945f689ca6842dcd8583fa5d3 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 26 Aug 2025 00:19:28 +0000 Subject: [PATCH 2/3] Only mount repo if not already exists --- setup-cvmfs.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup-cvmfs.sh b/setup-cvmfs.sh index 67c1e50..86cffff 100755 --- a/setup-cvmfs.sh +++ b/setup-cvmfs.sh @@ -81,7 +81,9 @@ if [ "$(uname)" == "Linux" ]; then # Mount CVMFS repositories (in case no autofs) for repo in $(echo ${CVMFS_REPOSITORIES} | sed "s/,/ /g") do - sudo mount -t cvmfs ${repo} /cvmfs/${repo} + if [ ! -d /cvmfs/${repo} ]; then + sudo mount -t cvmfs ${repo} /cvmfs/${repo} + fi done elif [ "$(uname)" == "Darwin" ]; then # Mount CVMFS repositories (no autofs available) From 58aef518c5b4e8f3e18bfc01bc12838a47d841a3 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 25 Aug 2025 19:39:09 -0500 Subject: [PATCH 3/3] Apply suggestions from code review --- README.devcontainer-feature.md | 2 +- README.md | 2 +- devcontainer-feature.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.devcontainer-feature.md b/README.devcontainer-feature.md index 8e85087..4d425a2 100644 --- a/README.devcontainer-feature.md +++ b/README.devcontainer-feature.md @@ -29,7 +29,7 @@ This feature is intended to be published to the GitHub Container Registry (GHCR) 4. **Publish the Feature:** Run the following command from the root of this repository. The namespace should match the GitHub organization (`cvmfs-contrib`). ```bash - devcontainer features publish src/cvmfs --namespace cvmfs-contrib/ + devcontainer features publish --namespace cvmfs-contrib/github-action-cvmfs . ``` ### Automated Publishing diff --git a/README.md b/README.md index 03a2d17..5c0ba4f 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ For example, you can add the following to your `devcontainer.json` to use this f "name": "CVMFS Action Dev", "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { - "ghcr.io/cvmfs-contrib/features/cvmfs": { + "ghcr.io/cvmfs-contrib/github-action-cvmfs/cvmfs": { "CVMFS_REPOSITORIES": "sft.cern.ch" } } diff --git a/devcontainer-feature.json b/devcontainer-feature.json index db6b477..84d7baf 100644 --- a/devcontainer-feature.json +++ b/devcontainer-feature.json @@ -17,7 +17,7 @@ "CVMFS_HTTP_PROXY": { "type": "string", "default": "DIRECT", - "description": "Chain of HTTP proxy groups used by CernVM-FS. Defaults to DIRECT)" + "description": "Chain of HTTP proxy groups used by CernVM-FS. Defaults to DIRECT." } }, "entrypoint": "install-cvmfs-linux.sh"