Skip to content
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
15 changes: 15 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
early_access: false
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: true
review_status: true
review_details: false
path_filters: ["!**/lib/**"]
auto_review:
enabled: true
drafts: false
chat:
auto_reply: true
55 changes: 0 additions & 55 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,58 +38,3 @@ jobs:
- name: Build
run: |
pnpm build

test:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest

name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6

- name: Setup GitHub SSH
uses: ./
id: github
with:
host: github.com
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITHUB }}

- name: Clone GitHub repository
run: |
git clone git@github.com:MrSquaare/private-repository.git

- name: Run tests for GitHub
env:
OUTPUT_SSH_PATH: ${{ steps.github.outputs.ssh-path }}
OUTPUT_SSH_AGENT_PID: ${{ steps.github.outputs.ssh-agent-pid }}
OUTPUT_SSH_AUTH_SOCK: ${{ steps.github.outputs.ssh-auth-sock }}
run: |
sh ./test/test.sh

- name: Setup GitLab SSH
uses: ./
id: gitlab
with:
# GitLab supports SSH on port 443
# See https://docs.gitlab.com/user/gitlab_com/#alternative-ssh-port
host: altssh.gitlab.com
port: 443
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
private-key-name: gitlab

- name: Clone GitLab repository
run: |
rm -rf private-repository
git clone ssh://git@altssh.gitlab.com:443/MrSquaare/private-repository.git

- name: Run tests for GitLab
env:
OUTPUT_SSH_PATH: ${{ steps.gitlab.outputs.ssh-path }}
OUTPUT_SSH_AGENT_PID: ${{ steps.gitlab.outputs.ssh-agent-pid }}
OUTPUT_SSH_AUTH_SOCK: ${{ steps.gitlab.outputs.ssh-auth-sock }}
run: |
sh ./test/test.sh
204 changes: 204 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: Tests

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
single-key-and-clone:
name: Single key and clone
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Setup fixtures
id: fixture
run: sh ./test/single-test.sh setup
env:
TMPDIR: ${{ runner.temp }}

- name: Start git server
id: git
run: sh ./test/git-server.sh start "${{ steps.fixture.outputs.case_dir }}" "${{ steps.fixture.outputs.port }}" "${{ steps.fixture.outputs.ssh_dir }}" "${{ steps.fixture.outputs.repos_dir }}"

- name: Setup SSH action
id: setup_ssh
uses: ./
with:
host: ${{ steps.fixture.outputs.host }}
port: ${{ steps.fixture.outputs.port }}
private-key: ${{ steps.fixture.outputs.private_key }}
private-key-name: id_rsa

- name: Verify test
run: sh ./test/single-test.sh verify
env:
TEST_CASE_DIR: ${{ steps.fixture.outputs.case_dir }}
TEST_SSH_USER: ${{ steps.fixture.outputs.ssh_user }}
TEST_SSH_PORT: ${{ steps.fixture.outputs.port }}
REPO_ONE: ${{ steps.fixture.outputs.repo_one }}
ACTION_SSH_PATH: ${{ env.SSH_PATH }}
ACTION_SSH_AGENT_PID: ${{ env.SSH_AGENT_PID }}
ACTION_SSH_AUTH_SOCK: ${{ env.SSH_AUTH_SOCK }}
OUTPUT_SSH_PATH: ${{ steps.setup_ssh.outputs.ssh-path }}
OUTPUT_SSH_AGENT_PID: ${{ steps.setup_ssh.outputs.ssh-agent-pid }}
OUTPUT_SSH_AUTH_SOCK: ${{ steps.setup_ssh.outputs.ssh-auth-sock }}

multiple-keys-and-clone:
name: Multiple keys and multiple clone
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Setup fixtures
id: fixture
run: sh ./test/multiple-test.sh setup
env:
TMPDIR: ${{ runner.temp }}

- name: Start git server
id: git
run: sh ./test/git-server.sh start "${{ steps.fixture.outputs.case_dir }}" "${{ steps.fixture.outputs.port }}" "${{ steps.fixture.outputs.ssh_dir }}" "${{ steps.fixture.outputs.repos_dir }}"

- name: Setup key 1
id: key1
uses: ./
with:
host: ${{ steps.fixture.outputs.host }}
port: ${{ steps.fixture.outputs.port }}
private-key: ${{ steps.fixture.outputs.private_key_github }}
private-key-name: github

- name: Setup key 2
id: key2
uses: ./
with:
host: ${{ steps.fixture.outputs.host }}
port: ${{ steps.fixture.outputs.port }}
private-key: ${{ steps.fixture.outputs.private_key_gitlab }}
private-key-name: gitlab

- name: Setup key 3
id: key3
uses: ./
with:
host: ${{ steps.fixture.outputs.host }}
port: ${{ steps.fixture.outputs.port }}
private-key: ${{ steps.fixture.outputs.private_key_server }}
private-key-name: server

- name: Verify test
run: sh ./test/multiple-test.sh verify
env:
TEST_CASE_DIR: ${{ steps.fixture.outputs.case_dir }}
TEST_SSH_USER: ${{ steps.fixture.outputs.ssh_user }}
TEST_SSH_PORT: ${{ steps.fixture.outputs.port }}
REPO_ONE: ${{ steps.fixture.outputs.repo_one }}
REPO_TWO: ${{ steps.fixture.outputs.repo_two }}
ACTION1_SSH_AGENT_PID: ${{ steps.key1.outputs.ssh-agent-pid }}
ACTION1_SSH_AUTH_SOCK: ${{ steps.key1.outputs.ssh-auth-sock }}
ACTION2_SSH_AGENT_PID: ${{ steps.key2.outputs.ssh-agent-pid }}
ACTION2_SSH_AUTH_SOCK: ${{ steps.key2.outputs.ssh-auth-sock }}
ACTION3_SSH_AGENT_PID: ${{ steps.key3.outputs.ssh-agent-pid }}
ACTION3_SSH_AUTH_SOCK: ${{ steps.key3.outputs.ssh-auth-sock }}
ACTION3_SSH_PATH: ${{ env.SSH_PATH }}

reuse-with-stale-env:
name: Reuse with stale env
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Setup fixtures
id: fixture
run: sh ./test/multiple-reuse-stale-test.sh setup
env:
TMPDIR: ${{ runner.temp }}

- name: Start git server
id: git
run: sh ./test/git-server.sh start "${{ steps.fixture.outputs.case_dir }}" "${{ steps.fixture.outputs.port }}" "${{ steps.fixture.outputs.ssh_dir }}" "${{ steps.fixture.outputs.repos_dir }}"

- name: Setup key with stale env
id: setup_ssh
uses: ./
env:
SSH_AUTH_SOCK: /tmp/non-existent.sock
SSH_AGENT_PID: "999999"
with:
host: ${{ steps.fixture.outputs.host }}
port: ${{ steps.fixture.outputs.port }}
private-key: ${{ steps.fixture.outputs.private_key }}
private-key-name: stale

- name: Verify test
run: sh ./test/multiple-reuse-stale-test.sh verify
env:
TEST_CASE_DIR: ${{ steps.fixture.outputs.case_dir }}
TEST_SSH_USER: ${{ steps.fixture.outputs.ssh_user }}
TEST_SSH_PORT: ${{ steps.fixture.outputs.port }}
REPO_ONE: ${{ steps.fixture.outputs.repo_one }}
ACTION_SSH_AGENT_PID: ${{ steps.setup_ssh.outputs.ssh-agent-pid }}
ACTION_SSH_AUTH_SOCK: ${{ steps.setup_ssh.outputs.ssh-auth-sock }}
ACTION_SSH_PATH: ${{ env.SSH_PATH }}
FAKE_SSH_AGENT_PID: "999999"
FAKE_SSH_AUTH_SOCK: /tmp/non-existent.sock

action-not-called-fails:
name: Action not called should fail clone
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Setup fixtures
id: fixture
run: sh ./test/no-action-test.sh setup
env:
TMPDIR: ${{ runner.temp }}

- name: Start git server
id: git
run: sh ./test/git-server.sh start "${{ steps.fixture.outputs.case_dir }}" "${{ steps.fixture.outputs.port }}" "${{ steps.fixture.outputs.ssh_dir }}" "${{ steps.fixture.outputs.repos_dir }}"

- name: Verify no-action failure
run: sh ./test/no-action-test.sh verify
env:
TEST_CASE_DIR: ${{ steps.fixture.outputs.case_dir }}
TEST_SSH_USER: ${{ steps.fixture.outputs.ssh_user }}
TEST_SSH_PORT: ${{ steps.fixture.outputs.port }}
REPO_ONE: ${{ steps.fixture.outputs.repo_one }}

missing-private-key-fails:
name: Missing private key should fail action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Setup fixtures
id: fixture
run: sh ./test/missing-private-key-test.sh setup
env:
TMPDIR: ${{ runner.temp }}

- name: Start git server
id: git
run: sh ./test/git-server.sh start "${{ steps.fixture.outputs.case_dir }}" "${{ steps.fixture.outputs.port }}" "${{ steps.fixture.outputs.ssh_dir }}" "${{ steps.fixture.outputs.repos_dir }}"

- name: Run action without private key
id: missing_key_action
continue-on-error: true
uses: ./
with:
host: ${{ steps.fixture.outputs.host }}
port: ${{ steps.fixture.outputs.port }}

- name: Verify missing-key failure
run: sh ./test/missing-private-key-test.sh verify
env:
TEST_CASE_DIR: ${{ steps.fixture.outputs.case_dir }}
TEST_SSH_USER: ${{ steps.fixture.outputs.ssh_user }}
TEST_SSH_PORT: ${{ steps.fixture.outputs.port }}
REPO_ONE: ${{ steps.fixture.outputs.repo_one }}
ACTION_OUTCOME: ${{ steps.missing_key_action.outcome }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ keys/
# Node
node_modules/

# pnpm
.pnpm-store/

# Jetbrains
.idea/

# Visual Studio Code
.vscode/

# macOS
.DS_Store
10 changes: 2 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,10 @@ pnpm build

## Testing

Lint the code:
Check the code:

```shell script
pnpm lint
```

Format the code:

```shell script
pnpm format
pnpm check
```

Run workflows with [act](https://github.com/nektos/act):
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
with:
host: 1.2.3.4
port: 8000
private-key: ${{ secrets.SSH_PRIVATE_KEY_GITLAB }}
private-key: ${{ secrets.SSH_PRIVATE_KEY_CUSTOM }}
private-key-name: server
- name: Clone GitHub repository
run: git clone git@github.com:username/repository.git
Expand Down
Loading
Loading