Skip to content

Commit

Permalink
feat(polyfills): add docker and aws-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
JPBM135 committed Jan 18, 2024
1 parent 34a13da commit 98df718
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const POLYFILLS: Record<PolyfillKey, PolyfillLib> = {
'dpkg-dev': { default: true, needs: [], aptPackage: 'dpkg-dev' },
'fonts-noto-color-emoji': { default: false, needs: [], aptPackage: 'fonts-noto-color-emoji' },
'g++': { default: true, needs: [], aptPackage: 'g++' },
'gnome-terminal': { default: true, needs: [], aptPackage: 'gnome-terminal' },
'iputils-ping': { default: false, needs: [], aptPackage: 'iputils-ping' },
'libffi-dev': { default: true, needs: [], aptPackage: 'libffi-dev' },
'libgbm-dev': { default: true, needs: [], aptPackage: 'libgbm-dev' },
Expand Down Expand Up @@ -61,7 +62,6 @@ export const POLYFILLS: Record<PolyfillKey, PolyfillLib> = {
libtool: { default: true, needs: [], aptPackage: 'libtool' },
libunwind8: { default: true, needs: [], aptPackage: 'libunwind8' },
libxss1: { default: true, needs: [], aptPackage: 'libxss1' },

locales: { default: false, needs: [], aptPackage: 'locales' },
lz4: { default: false, needs: [], aptPackage: 'lz4' },
m4: { default: false, needs: [], aptPackage: 'm4' },
Expand Down Expand Up @@ -106,4 +106,25 @@ export const POLYFILLS: Record<PolyfillKey, PolyfillLib> = {
path: '$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH',
command: 'curl -o- -L https://yarnpkg.com/install.sh | bash || true',
},
docker: {
default: true,
needs: ['gnome-terminal', 'curl', 'gnupg', 'ca-certificates'],
command: [
'sudo install -m 0755 -d /etc/apt/keyrings',
'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg',
'sudo chmod a+r /etc/apt/keyrings/docker.gpg',
'echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null',
'sudo apt-get update',
'sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin',
].join(' && '),
},
'aws-cli': {
default: true,
needs: [],
command: [
'curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"',
'unzip awscliv2.zip',
'sudo ./aws/install',
].join(' && '),
},
};
6 changes: 5 additions & 1 deletion src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Self-Hosted Actions Polyfill', () => {
await main();

expect(core.setFailed).not.toHaveBeenCalled();
expect(exec.exec).toHaveBeenCalledTimes(5);
expect(exec.exec).toHaveBeenCalledTimes(6);

expect(exec.exec).toHaveBeenCalledWith('sudo', ['apt-get', 'update', '-y'], expect.anything());

Expand All @@ -59,6 +59,10 @@ describe('Self-Hosted Actions Polyfill', () => {
expect.anything(),
);

expect(exec.exec).toHaveBeenCalledWith('/bin/bash', ['-c', POLYFILLS.docker?.command], expect.anything());

expect(exec.exec).toHaveBeenCalledWith('/bin/bash', ['-c', POLYFILLS['aws-cli']?.command], expect.anything());

expect(exec.exec).toHaveBeenLastCalledWith('sudo', ['apt-get', 'autoremove', '-y'], expect.anything());
});

Expand Down
3 changes: 3 additions & 0 deletions src/types/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type PolyfillKey =
| 'aria2'
| 'autoconf'
| 'automake'
| 'aws-cli'
| 'binutils'
| 'bison'
| 'brotli'
Expand All @@ -23,6 +24,7 @@ export type PolyfillKey =
| 'curl'
| 'dbus'
| 'dnsutils'
| 'docker'
| 'dpkg-dev'
| 'dpkg'
| 'fakeroot'
Expand All @@ -32,6 +34,7 @@ export type PolyfillKey =
| 'ftp'
| 'g++'
| 'gcc'
| 'gnome-terminal'
| 'gnupg'
| 'gnupg2'
| 'haveged'
Expand Down

0 comments on commit 98df718

Please sign in to comment.