Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: support Alpine + add setup-alpine package + detect externally managed python #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f737a07
feat: add setup-alpine package
aminya Mar 23, 2025
18f6af3
feat: support installing specific versions for alpine
aminya Mar 23, 2025
dd785ba
feat: add alpine installers for all tools
aminya Mar 23, 2025
3108fdc
ci: add docker images for testing alpine
aminya Mar 23, 2025
5a0bbaf
feat: install bash for alpine
aminya Mar 23, 2025
ba81f6a
fix: do not use root for apk update
aminya Mar 23, 2025
4c992d0
fix: fix pip package installation on alpine
aminya Mar 23, 2025
9a2e612
fix: do not use python prefix for pipx installation
aminya Mar 23, 2025
1158c50
fix: detect externally managed pythons
aminya Mar 23, 2025
4d2ad5f
fix: fix python3 prefix for alpine packages
aminya Mar 23, 2025
e6bd753
fix: do not try installing externally managed pip packages
aminya Mar 23, 2025
d04bcbf
fix: fix vcpkg deps on alpine
aminya Mar 23, 2025
bcc7fc2
fix: rename installApkPack for consistency
aminya Mar 23, 2025
5b56272
fix: fix pkgconf name for alpine
aminya Mar 23, 2025
0730cb5
fix: ensure env is set for the current process
aminya Mar 23, 2025
2ee99e2
fix: install cmake/ninja via system for alpine
aminya Mar 23, 2025
477dd40
fix: ignore version for doxygen on alpine
aminya Mar 23, 2025
d8d2cae
fix: fix llvm installation on alpine
aminya Mar 23, 2025
f23c0b8
fix: install base compilers for vcpkg on alpine
aminya Mar 23, 2025
ad49f54
fix: fix extraction deps on alpine
aminya Mar 23, 2025
8a0c8a7
fix: do not remove apk-tools
aminya Mar 23, 2025
ae24e96
fix: fix powershell/mingw installation on alpine
aminya Mar 23, 2025
d34b955
feat: support community repo for alpine
aminya Mar 23, 2025
24ed36b
fix: fix pipx installation on arch
aminya Mar 23, 2025
c04f432
test: add examples for alpine docker
aminya Mar 23, 2025
895d69e
fix: fix the docker entrypoint on Alpine
aminya Mar 23, 2025
8eb691a
ci: build alpine on Arm64
aminya Mar 23, 2025
6ecab5e
fix: fix ninja version on Alpine
aminya Mar 23, 2025
2e04f42
ci: do not test mingw on alpine
aminya Mar 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions 25 .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ jobs:
- { distro: "ubuntu", image: "setup-cpp-ubuntu", BASE_VERSION: "20.04", tag: "20.04-1.3.0" }
- { distro: "fedora", image: "setup-cpp-fedora", tag: "40-1.3.0" }
- { distro: "arch", image: "setup-cpp-arch", tag: "base-1.3.0" }
- { distro: "alpine", image: "setup-cpp-alpine", BASE_VERSION: "22-alpine3.21", tag: "3.21-1.3.0" }
include:
- os: ubuntu-24.04-arm
platform: linux/arm64
Expand All @@ -254,6 +255,9 @@ jobs:
- os: ubuntu-24.04-arm
platform: linux/arm64
container: { distro: "ubuntu", image: "setup-cpp-ubuntu", BASE_VERSION: "20.04", tag: "20.04-1.3.0" }
- os: ubuntu-24.04-arm
platform: linux/arm64
container: { distro: "alpine", image: "setup-cpp-alpine", BASE_VERSION: "22-alpine3.21", tag: "3.21-1.3.0" }
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -300,7 +304,7 @@ jobs:
docker tag aminya/${{ matrix.container.image }}:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}:latest

- name: Push latest to Docker Hub
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' && matrix.container.distro != 'alpine' }}
run: docker push aminya/${{ matrix.container.image }}:latest

- name: Docker Readme for setup-cpp-${{matrix.container.distro }}
Expand Down Expand Up @@ -331,7 +335,7 @@ jobs:
docker tag aminya/${{ matrix.container.image }}-llvm:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}-llvm:latest

- name: Push latest to Docker Hub
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' && matrix.container.distro != 'alpine' }}
run: docker push aminya/${{ matrix.container.image }}-llvm:latest

- name: Docker Readme for setup-cpp-${{matrix.container.distro }}-llvm
Expand Down Expand Up @@ -372,7 +376,7 @@ jobs:
docker tag aminya/${{ matrix.container.image }}-gcc:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}-gcc:latest

- name: Push latest to Docker Hub
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' && matrix.container.distro != 'alpine' }}
run: docker push aminya/${{ matrix.container.image }}-gcc:latest

- name: Docker Readme for setup-cpp-${{matrix.container.distro }}-gcc
Expand All @@ -396,7 +400,7 @@ jobs:

- name: Build setup-cpp-${{matrix.container.distro }}-mingw
id: build_mingw
if: ${{ matrix.container.distro != 'fedora' }}
if: ${{ matrix.container.distro != 'fedora' && !(matrix.container.distro == 'alpine' && matrix.platform == 'linux/arm64') }}
uses: docker/build-push-action@v6
with:
context: .
Expand All @@ -410,16 +414,16 @@ jobs:
cache-to: type=inline

- name: Tag latest locally
if: ${{ matrix.container.distro != 'fedora' }}
if: ${{ matrix.container.distro != 'fedora' && !(matrix.container.distro == 'alpine' && matrix.platform == 'linux/arm64') }}
run: |
docker tag aminya/${{ matrix.container.image }}-mingw:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}-mingw:latest

- name: Push latest to Docker Hub
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' && matrix.container.distro != 'fedora' }}
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' && matrix.container.distro != 'fedora' && matrix.container.distro != 'alpine' }}
run: docker push aminya/${{ matrix.container.image }}-mingw:latest

- name: Docker Readme for setup-cpp-${{matrix.container.distro }}-mingw
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'fedora' }}
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'fedora' && !(matrix.container.distro == 'alpine' && matrix.platform == 'linux/arm64') }}
uses: peter-evans/dockerhub-description@v4
with:
username: aminya
Expand All @@ -428,7 +432,7 @@ jobs:
readme-filepath: ./README_DOCKER.md

- name: Test Mingw
if: ${{ !contains(github.event.head_commit.message, '[skip test]') && matrix.container.distro != 'fedora' }}
if: ${{ !contains(github.event.head_commit.message, '[skip test]') && matrix.container.distro != 'fedora' && matrix.container.distro != 'alpine' }}
uses: docker/build-push-action@v6
with:
context: .
Expand Down Expand Up @@ -459,6 +463,11 @@ jobs:
- { distro: "ubuntu", image: "setup-cpp-ubuntu", tag: "24.04-1.3.0", suffix: "-llvm", latest: true }
- { distro: "ubuntu", image: "setup-cpp-ubuntu", tag: "24.04-1.3.0", suffix: "-gcc", latest: true }
- { distro: "ubuntu", image: "setup-cpp-ubuntu", tag: "24.04-1.3.0", suffix: "-mingw", latest: true }

- { distro: "alpine", image: "setup-cpp-alpine", tag: "3.21-1.3.0", suffix: "", latest: true }
- { distro: "alpine", image: "setup-cpp-alpine", tag: "3.21-1.3.0", suffix: "-llvm", latest: true }
- { distro: "alpine", image: "setup-cpp-alpine", tag: "3.21-1.3.0", suffix: "-gcc", latest: true }
- { distro: "alpine", image: "setup-cpp-alpine", tag: "3.21-1.3.0", suffix: "-mingw", latest: true }
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
10 changes: 10 additions & 0 deletions 10 dev/docker/ci/alpine-gcc.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM aminya/setup-cpp-alpine:latest AS setup-cpp-alpine-gcc

# install gcc
RUN node --enable-source-maps /usr/lib/setup-cpp/setup-cpp.mjs \
--compiler gcc && \
# cleanup
rm -rf /var/cache/apk/*

SHELL ["/entrypoint.sh", "/bin/sh", "-c"]
ENTRYPOINT ["/entrypoint.sh", "/bin/sh"]
10 changes: 10 additions & 0 deletions 10 dev/docker/ci/alpine-llvm.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM aminya/setup-cpp-alpine:latest AS setup-cpp-alpine-llvm

# install llvm
RUN node --enable-source-maps /usr/lib/setup-cpp/setup-cpp.mjs \
--compiler llvm && \
# cleanup
rm -rf /var/cache/apk/*

SHELL ["/entrypoint.sh", "/bin/sh", "-c"]
ENTRYPOINT ["/entrypoint.sh", "/bin/sh"]
11 changes: 11 additions & 0 deletions 11 dev/docker/ci/alpine-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM aminya/setup-cpp-alpine:latest AS setup-cpp-alpine-mingw

# install mingw/powershell
RUN node --enable-source-maps /usr/lib/setup-cpp/setup-cpp.mjs \
--compiler mingw \
--powershell true && \
# cleanup
rm -rf /var/cache/apk/*

SHELL ["/entrypoint.sh", "/bin/sh", "-c"]
ENTRYPOINT ["/entrypoint.sh", "/bin/sh"]
34 changes: 34 additions & 0 deletions 34 dev/docker/ci/alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG BASE_VERSION=22-alpine3.21

#### Base Image with Node.js
FROM --platform=$BUILDPLATFORM node:${BASE_VERSION} AS alpine-nodejs

#### Base Image with Tools
FROM alpine-nodejs AS setup-cpp-alpine

COPY "./dist/modern" "/usr/lib/setup-cpp/"

# install the cpp tools
RUN node --enable-source-maps /usr/lib/setup-cpp/setup-cpp.mjs \
--cmake true \
--ninja true \
--task true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--vcpkg true \
--ccache true \
--conan true \
--cmakelang true \
--meson true && \
# cleanup
rm -rf /var/cache/apk/*

# Custom entrypoint due to bash -l limitations on Alpine
RUN printf '#!/bin/bash\nsource $HOME/.cpprc\nexec "$@"\n' > /entrypoint.sh && \
chmod +x /entrypoint.sh

SHELL ["/entrypoint.sh", "/bin/sh", "-c"]
ENTRYPOINT ["/entrypoint.sh", "/bin/sh"]
15 changes: 15 additions & 0 deletions 15 dev/docker/examples/alpine-gcc.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#### Building (example)
FROM aminya/setup-cpp-alpine-gcc AS builder

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN task build

#### Running environment
# use a fresh image as the runner
FROM alpine:3.21 AS runner

# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]
15 changes: 15 additions & 0 deletions 15 dev/docker/examples/alpine-llvm.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#### Building (example)
FROM aminya/setup-cpp-alpine-llvm AS builder

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN task build

#### Running environment
# use a fresh image as the runner
FROM alpine:3.21 AS runner

# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]
7 changes: 7 additions & 0 deletions 7 dev/docker/examples/alpine-mingw.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#### Cross Building (example)
FROM aminya/setup-cpp-alpine-mingw AS builder-mingw

COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'
2 changes: 1 addition & 1 deletion 2 dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 2 dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 2 dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 2 dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions 2 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"safe-stable-stringify": "^2.5.0",
"semver": "7.7.1",
"setup-apt": "workspace:*",
"setup-alpine": "workspace:*",
"setup-brew": "workspace:*",
"setup-python": "github:aminya/setup-python#9700887",
"shx": "0.4.0",
Expand Down Expand Up @@ -184,6 +185,7 @@
"retry-as-promised",
"semver",
"setup-apt",
"setup-alpine",
"setup-brew",
"setup-python",
"simple-update-notifier",
Expand Down
2 changes: 1 addition & 1 deletion 2 packages/envosman/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "envosman",
"version": "1.0.3",
"version": "1.0.4",
"description": "Manage environment variables, PATH, and rc files",
"repository": "https://github.com/aminya/setup-cpp",
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/envosman",
Expand Down
2 changes: 2 additions & 0 deletions 2 packages/envosman/src/add-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ async function addEnvSystem(name: string, valGiven: string | undefined, options:
await appendFile(options.rcPath, `\nexport ${name}="${val}"\n`)
info(`${name}="${val}" was added to "${options.rcPath}`)
}
// eslint-disable-next-line require-atomic-updates
process.env[name] = val
return
}
default: {
Expand Down
3 changes: 3 additions & 0 deletions 3 packages/setup-alpine/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}
55 changes: 55 additions & 0 deletions 55 packages/setup-alpine/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "setup-alpine",
"version": "1.0.0",
"description": "Setup apk packages and repositories in Alpine Linux distributions",
"repository": "https://github.com/aminya/setup-cpp",
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-alpine",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"source": "./src/index.ts",
"type": "module",
"files": [
"dist",
"src",
"tsconfig.json"
],
"scripts": {
"build": "tsc --pretty",
"dev": "tsc --watch --pretty",
"lint.tsc": "tsc --noEmit --pretty",
"lint.eslint": "eslint '**/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml}' --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@types/node": "22.13.11",
"admina": "^1.0.1",
"ci-info": "^4.0.0",
"path-exists": "^5.0.0",
"ci-log": "workspace:*",
"envosman": "workspace:*",
"which": "4.0.0",
"execa": "7.2.0",
"memoizee": "^0.4.17"
},
"engines": {
"node": ">=12"
},
"keywords": [
"setup",
"apk",
"apk-add",
"repository",
"alpine",
"install",
"setup-apk",
"repositories",
"linux",
"alpine-linux",
"package"
],
"devDependencies": {
"@types/memoizee": "0.4.11",
"@types/which": "~3.0.4"
}
}
60 changes: 60 additions & 0 deletions 60 packages/setup-alpine/src/apk-repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { info } from "ci-log"
import { appendFile, readFile } from "fs/promises"
import { pathExists } from "path-exists"
import { hasApk } from "./has-apk.js"
import { updateApkMemoized } from "./update.js"

/**
* Add an APK repository
* @param repoUrl The URL of the repository to add
* @returns Whether the repository was added successfully
*/

export async function addApkRepository(repoUrl: string): Promise<boolean> {
if (!(await hasApk())) {
throw new Error("apk is not available on this system")
}

try {
// Check if repositories file exists
const reposFile = "/etc/apk/repositories"
if (!(await pathExists(reposFile))) {
throw new Error(`APK repositories file not found at ${reposFile}`)
}

// Add repository to the file
info(`Adding repository: ${repoUrl}`)
await appendFile(reposFile, `${repoUrl}\n`)

// Update package index after adding repository
await updateApkMemoized.clear()
await updateApkMemoized()

info(`Successfully added repository: ${repoUrl}`)
return true
} catch (error) {
throw new Error(`Failed to add repository ${repoUrl}: ${error}`)
}
}

/**
* Enable the community repository
* @returns Whether the repository was added successfully
*/
export async function enableCommunityRepository() {
const alpineVersion = (await getAlpineVersion()).split(".").slice(0, 2).join(".")

return addApkRepository(`https://dl-cdn.alpinelinux.org/alpine/v${alpineVersion}/community/`)
}

/**
* Get the Alpine version
* @returns The Alpine version
*/
export async function getAlpineVersion() {
const releaseFile = "/etc/alpine-release"
if (!(await pathExists(releaseFile))) {
throw new Error(`Alpine release file not found at ${releaseFile}`)
}
return readFile(releaseFile, "utf8")
}
15 changes: 15 additions & 0 deletions 15 packages/setup-alpine/src/has-apk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import memoizee from "memoizee"
import which from "which"

async function hasApk_() {
try {
await which("apk")
return true
} catch (error) {
return false
}
}
/**
* Check if apk is available on the system
*/
export const hasApk = memoizee(hasApk_, { promise: true })
6 changes: 6 additions & 0 deletions 6 packages/setup-alpine/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from "./apk-repository.js"
export * from "./has-apk.js"
export * from "./init-apt.js"
export * from "./install-package.js"
export * from "./qualify-install.js"
export * from "./update.js"
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.