Skip to content
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

Add Alpine (apk package manager) native install support #145

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
run: |
[[ ${{ steps.restore-keys.outputs.test-cache-hit }} = true ]]

test_docker:
test_docker_ubuntu:
# Test that it works in a Docker container without sudo.
runs-on: ubuntu-latest
container: ubuntu:latest
Expand All @@ -174,6 +174,17 @@ jobs:
- name: Run ccache-action
uses: ./

test_docker_alpine:
# Test that it works in Alpine Docker container with apk package manager.
runs-on: ubuntu-latest
container: alpine:latest
steps:
- uses: actions/checkout@v2
- run: apk update
shell: sh
- name: Run ccache-action
uses: ./

test_option_save:
# Test that the 'save' option is available.
runs-on: ubuntu-latest
Expand Down
13 changes: 9 additions & 4 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59426,10 +59426,15 @@ async function installCcacheMac() {
await execBash("brew install ccache");
}
async function installCcacheLinux() {
if (!await io.which("apt-get")) {
throw Error("Can't install ccache automatically under this platform, please install it yourself before using this action.");
if (await io.which("apt-get")) {
await execBashSudo("apt-get install -y ccache");
return;
}
else if (await io.which("apk")) {
await execBash("apk add ccache");
return;
}
await execBashSudo("apt-get install -y ccache");
throw Error("Can't install ccache automatically under this platform, please install it yourself before using this action.");
}
async function installCcacheWindows() {
await installCcacheFromGitHub("4.7.4", "windows-x86_64",
Expand All @@ -59450,7 +59455,7 @@ async function installSccacheWindows() {
`${external_process_namespaceObject.env.USERPROFILE}\\.cargo\\bin`, "sccache.exe");
}
async function execBash(cmd) {
await exec.exec("bash", ["-xc", cmd]);
await exec.exec("sh", ["-xc", cmd]);
}
async function execBashSudo(cmd) {
await execBash("$(which sudo) " + cmd);
Expand Down
12 changes: 8 additions & 4 deletions src/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ async function installCcacheMac() : Promise<void> {
}

async function installCcacheLinux() : Promise<void> {
if (!await io.which("apt-get")) {
throw Error("Can't install ccache automatically under this platform, please install it yourself before using this action.")
if (await io.which("apt-get")) {
await execBashSudo("apt-get install -y ccache");
return;
} else if (await io.which("apk")) {
await execBash("apk add ccache");
return;
}
await execBashSudo("apt-get install -y ccache");
throw Error("Can't install ccache automatically under this platform, please install it yourself before using this action.");
}

async function installCcacheWindows() : Promise<void> {
Expand Down Expand Up @@ -106,7 +110,7 @@ async function installSccacheWindows() : Promise<void> {
}

async function execBash(cmd : string) {
await exec.exec("bash", ["-xc", cmd]);
await exec.exec("sh", ["-xc", cmd]);
}

async function execBashSudo(cmd : string) {
Expand Down