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
5 changes: 5 additions & 0 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ name: Commit
on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
commits:
name: Check Commits
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: free disk space
uses: jlumbroso/free-disk-space@ceedf095f4ec1a097402bc6bd80831f2e1a6fde6 # v2.0.0
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
check:
name: Pre-commit Checks
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

Expand Down
108 changes: 22 additions & 86 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@ on:
workflow_dispatch:
inputs:
core_tag:
description: >-
Core release tag to qualify with this provider checkout (for example
v1.25.0-beta.8). Runs the release-qualification job.
description: Core release tag to qualify, for example v1.25.0-beta.8. Leave empty to skip qualification.
required: false
type: string
provider_tag:
description: Published SSH provider release to qualify
required: true
required: false
default: v1.1.47
type: string

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
test:
name: Integration tests (compatibility core v1.24.0, not release qualification)
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
Expand All @@ -34,7 +40,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y bash zsh fish openssh-server

- name: unit tests
run: go test -race -covermode=atomic . ./cmd/... ./hack/... ./pkg/...
run: go test -race -covermode=atomic . ./cmd/... ./hack/... ./pkg/... ./e2e/qualification/...
env:
CGO_ENABLED: "1"

Expand All @@ -56,11 +62,7 @@ jobs:
du -sh "$(go env GOCACHE)" "$(go env GOMODCACHE)"

- name: provision login shell accounts
run: |
sudo service ssh start
for shell in bash zsh fish; do
sudo useradd --create-home --shell "$(command -v "$shell")" "devsy-$shell"
done
run: go run ./hack/ci provision-accounts

- name: integration tests
working-directory: ./e2e
Expand All @@ -71,6 +73,7 @@ jobs:
windows-stdin:
name: Windows redirected SSH stdin
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
Expand All @@ -90,8 +93,6 @@ jobs:
fail-fast: false
matrix:
core_artifact: [cli, desktop]
permissions:
contents: read
env:
CORE_TAG: ${{ inputs.core_tag }}
CORE_REPO: devsy-org/devsy
Expand Down Expand Up @@ -121,59 +122,17 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y bash zsh fish openssh-server

- name: download and verify the released provider
run: |
set -euo pipefail
mkdir -p dist/build_linux_amd64_v1
asset=devsy-provider-ssh-linux-amd64
gh release download "$PROVIDER_TAG" --repo "$GITHUB_REPOSITORY" \
--pattern "$asset" --dir dist/build_linux_amd64_v1 --clobber
gh release download "$PROVIDER_TAG" --repo "$GITHUB_REPOSITORY" \
--pattern checksums.txt --dir dist --clobber
binary="dist/build_linux_amd64_v1/$asset"
digest="$(sha256sum "$binary" | cut -d' ' -f1)"
published_digest="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$PROVIDER_TAG" \
--jq ".assets[] | select(.name == \"$asset\") | .digest")"
if [ "$published_digest" != "sha256:$digest" ]; then
echo "::error::downloaded provider sha256:$digest differs from '$published_digest'"
exit 1
fi
chmod 0755 "$binary"
echo "provider binary sha256: $digest (matches published release digest)" \
| tee -a "$QUALIFICATION_DIR/pair-verification.txt" >> "$GITHUB_STEP_SUMMARY"
run: go run ./hack/ci verify-provider
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: require the explicit candidate before SSH setup
working-directory: ./e2e
run: |
status=0
env -u DEVSY_E2E_BINARY go test -v -timeout 300s --ginkgo.v \
--ginkgo.label-filter=release-qualification \
--ginkgo.focus='bash builtin=false installs a cold agent by remote download' \
> "$QUALIFICATION_DIR/missing-binary-guard.log" 2>&1 || status=$?
cat "$QUALIFICATION_DIR/missing-binary-guard.log"
test "$status" -eq 1
grep -F 'DEVSY_E2E_BINARY is required' "$QUALIFICATION_DIR/missing-binary-guard.log"
run: go run ./hack/ci missing-candidate-guard
env:
DEVSY_E2E_RELEASE_QUALIFICATION: "true"

- name: provision login shell accounts
run: |
sudo service ssh start
for shell in bash zsh fish; do
sudo useradd --create-home --shell "$(command -v "$shell")" "devsy-$shell"
sudo usermod --append --groups docker "devsy-$shell"
done
sudo useradd --create-home --shell "$(command -v bash)" --groups docker devsy-sudo
policy=/etc/sudoers.d/devsy-e2e-qualification
sudo test ! -e "$policy"
rule="$(mktemp)"
trap 'rm -f "$rule"' EXIT
printf '%s\n' 'devsy-sudo ALL=(root) NOPASSWD: SETENV: /bin/sh -c * devsy-install *' > "$rule"
sudo visudo -cf "$rule"
echo "DEVSY_SUDO_FIXTURE_POLICY=$policy" >> "$GITHUB_ENV"
sudo install -m 0440 -o root -g root "$rule" "$policy"
sudo visudo -cf "$policy"
- name: provision qualification accounts
run: go run ./hack/ci provision-qualification-accounts

- name: qualify login shells with the explicit pair
working-directory: ./e2e
Expand All @@ -185,35 +144,12 @@ jobs:
DEVSY_E2E_SHELL_MATRIX: "true"
DEVSY_E2E_REPORT: ${{ runner.temp }}/qualification/qualification-report.json

- name: remove owned sudo fixture policy
if: always() && env.DEVSY_SUDO_FIXTURE_POLICY != ''
run: sudo rm -f -- "$DEVSY_SUDO_FIXTURE_POLICY"
- name: remove qualification accounts and sudo fixture
if: always()
run: go run ./hack/ci cleanup-qualification-accounts

- name: require a complete, passing report
run: |
jq -e --arg sha "$CORE_SHA256" '
.pair.coreBinarySha256 == $sha
and (.cells | length == 6)
and ([.cells[] | [.shell, .builtinSsh]] | unique | length == 6)
and all(.cells[];
.cleanup == "ok"
and (.scenarios | length == 5)
and all(.scenarios[]; .outcome == "passed")
and (.agentDir | contains(" ") and contains("\u0027")
and contains("\\") and contains("$") and contains("\u03bb"))
and .agentSha256.download == $sha
and .agentSha256.stdin == $sha)
and .privilege.user == "devsy-sudo"
and .privilege.userUid > 0
and .privilege.directoryState == "0:755"
and .privilege.writeDenied == true
and .privilege.agentUid == 0
and .privilege.agentVersion == .pair.coreVersion
and .privilege.agentSha256 == $sha
and .privilege.liveCommand == true
and .privilege.outcome == "passed"
and .privilege.cleanup == "ok"
' "$QUALIFICATION_DIR/qualification-report.json"
- name: verify the qualification report
run: go run ./hack/ci verify-report

- name: upload qualification report
if: always()
Expand Down
14 changes: 11 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ linters:
- whitespace
exclusions:
rules:
- path: hack/ci/qualify\.go
- path: 'hack/ci/(qualify|verify_provider)\.go'
linters:
- gosec
text: 'G302: Expect file permissions to be 0600 or less'
- path: hack/ci/qualify\.go
- path: 'hack/ci/(exec|guard)\.go'
linters:
- gosec
text: 'G204: Subprocess launched with variable'
text: 'G204|G702'
- path: 'hack/ci/provision_test\.go'
linters:
- gosec
text: 'G703'
- path: 'e2e/qualification/report\.go'
linters:
- gosec
text: 'G304'
settings:
cyclop:
max-complexity: 8
Expand Down
Loading
Loading