Skip to content

Commit af7790f

Browse files
authored
Merge branch 'main' into fly-wsproxy
2 parents 6dfc2e7 + 15875a7 commit af7790f

File tree

9 files changed

+326
-187
lines changed

9 files changed

+326
-187
lines changed

.github/workflows/ci.yaml

Lines changed: 199 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
outputs:
3333
docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
34+
docs: ${{ steps.filter.outputs.docs }}
3435
go: ${{ steps.filter.outputs.go }}
3536
ts: ${{ steps.filter.outputs.ts }}
3637
k8s: ${{ steps.filter.outputs.k8s }}
@@ -388,120 +389,6 @@ jobs:
388389
with:
389390
api-key: ${{ secrets.DATADOG_API_KEY }}
390391

391-
deploy:
392-
name: "deploy"
393-
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
394-
timeout-minutes: 30
395-
needs: changes
396-
if: |
397-
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
398-
&& needs.changes.outputs.docs-only == 'false'
399-
permissions:
400-
contents: read
401-
id-token: write
402-
steps:
403-
- name: Checkout
404-
uses: actions/checkout@v4
405-
with:
406-
fetch-depth: 0
407-
408-
- name: Authenticate to Google Cloud
409-
uses: google-github-actions/auth@v1
410-
with:
411-
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
412-
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
413-
414-
- name: Set up Google Cloud SDK
415-
uses: google-github-actions/setup-gcloud@v1
416-
417-
- name: Setup Node
418-
uses: ./.github/actions/setup-node
419-
420-
- name: Setup Go
421-
uses: ./.github/actions/setup-go
422-
423-
- name: Install goimports
424-
run: go install golang.org/x/tools/cmd/goimports@latest
425-
- name: Install nfpm
426-
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
427-
428-
- name: Install zstd
429-
run: sudo apt-get install -y zstd
430-
431-
- name: Build Release
432-
run: |
433-
set -euo pipefail
434-
go mod download
435-
436-
version="$(./scripts/version.sh)"
437-
make gen/mark-fresh
438-
make -j \
439-
build/coder_"$version"_windows_amd64.zip \
440-
build/coder_"$version"_linux_amd64.{tar.gz,deb}
441-
442-
- name: Install Release
443-
run: |
444-
set -euo pipefail
445-
446-
regions=(
447-
# gcp-region-id instance-name systemd-service-name
448-
"us-central1-a coder coder"
449-
"australia-southeast1-b coder-sydney coder-workspace-proxy"
450-
"europe-west3-c coder-europe coder-workspace-proxy"
451-
"southamerica-east1-b coder-brazil coder-workspace-proxy"
452-
)
453-
454-
deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
455-
if [ ! -f "$deb_pkg" ]; then
456-
echo "deb package not found: $deb_pkg"
457-
ls -l ./build
458-
exit 1
459-
fi
460-
461-
gcloud config set project coder-dogfood
462-
for region in "${regions[@]}"; do
463-
echo "::group::$region"
464-
set -- $region
465-
466-
set -x
467-
gcloud config set compute/zone "$1"
468-
gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
469-
gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
470-
set +x
471-
472-
echo "::endgroup::"
473-
done
474-
475-
- name: Upload build artifacts
476-
uses: actions/upload-artifact@v3
477-
with:
478-
name: coder
479-
path: |
480-
./build/*.zip
481-
./build/*.tar.gz
482-
./build/*.deb
483-
retention-days: 7
484-
485-
deploy-wsproxies:
486-
runs-on: ubuntu-latest
487-
needs: build-main-image
488-
steps:
489-
- name: Checkout
490-
uses: actions/checkout@v4
491-
with:
492-
fetch-depth: 0
493-
494-
- name: Setup flyctl
495-
uses: superfly/flyctl-actions/setup-flyctl@master
496-
497-
- name: Deploy workspace proxies
498-
run: |
499-
flyctl deploy --image ghcr.io/coder/coder-preview:main --app paris-coder -y
500-
flyctl deploy --image ghcr.io/coder/coder-preview:main --app sydney-coder -y
501-
flyctl deploy --image ghcr.io/coder/coder-preview:main --app sao-paulo-coder -y
502-
env:
503-
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
504-
505392
test-js:
506393
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
507394
needs: changes
@@ -667,7 +554,8 @@ jobs:
667554
name: offlinedocs
668555
needs: changes
669556
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
670-
if: needs.changes.outputs.offlinedocs == 'true' || needs.changes.outputs.ci == 'true'
557+
if: needs.changes.outputs.offlinedocs == 'true' || needs.changes.outputs.ci == 'true' || needs.changes.outputs.docs == 'true'
558+
671559
steps:
672560
- name: Checkout
673561
uses: actions/checkout@v4
@@ -740,9 +628,10 @@ jobs:
740628
741629
echo "Required checks have passed"
742630
743-
build-main-image:
744-
# This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch.
745-
# We are only building this for amd64 plateform. (>95% pulls are for amd64)
631+
build:
632+
# This builds and publishes ghcr.io/coder/coder-preview:main for each commit
633+
# to main branch. We are only building this for amd64 platform. (>95% pulls
634+
# are for amd64)
746635
needs: changes
747636
if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
748637
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
@@ -770,27 +659,34 @@ jobs:
770659
username: ${{ github.actor }}
771660
password: ${{ secrets.GITHUB_TOKEN }}
772661

773-
- name: Build and push Linux amd64 Docker image
774-
id: build_and_push
662+
- name: Build
775663
run: |
776664
set -euxo pipefail
777665
go mod download
778-
make gen/mark-fresh
779-
export DOCKER_IMAGE_NO_PREREQUISITES=true
666+
780667
version="$(./scripts/version.sh)"
668+
make gen/mark-fresh
669+
make -j \
670+
build/coder_linux_amd64 \
671+
build/coder_"$version"_windows_amd64.zip \
672+
build/coder_"$version"_linux_amd64.{tar.gz,deb}
673+
674+
- name: Build and Push Linux amd64 Docker Image
675+
run: |
676+
set -euxo pipefail
677+
tag="main-$(echo "$version" | sed 's/+/-/g')"
678+
781679
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
782-
make -j build/coder_linux_amd64
783680
./scripts/build_docker.sh \
784681
--arch amd64 \
785-
--target ghcr.io/coder/coder-preview:main \
682+
--target "ghcr.io/coder/coder-preview:$tag" \
786683
--version $version \
787684
--push \
788685
build/coder_linux_amd64
789686
790-
# Tag image with new package tag and push
791-
tag=$(echo "$version" | sed 's/+/-/g')
792-
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag
793-
docker push ghcr.io/coder/coder-preview:main-$tag
687+
# Tag as main
688+
docker tag "ghcr.io/coder/coder-preview:$tag" ghcr.io/coder/coder-preview:main
689+
docker push ghcr.io/coder/coder-preview:main
794690
795691
- name: Prune old images
796692
uses: vlaurin/action-ghcr-prune@v0.5.0
@@ -802,3 +698,178 @@ jobs:
802698
keep-tags-regexes: ^pr
803699
prune-tags-regexes: ^main-
804700
prune-untagged: true
701+
702+
- name: Upload build artifacts
703+
uses: actions/upload-artifact@v3
704+
with:
705+
name: coder
706+
path: |
707+
./build/*.zip
708+
./build/*.tar.gz
709+
./build/*.deb
710+
retention-days: 7
711+
712+
deploy:
713+
name: "deploy"
714+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
715+
timeout-minutes: 30
716+
needs:
717+
- changes
718+
- build
719+
if: |
720+
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
721+
&& needs.changes.outputs.docs-only == 'false'
722+
permissions:
723+
contents: read
724+
id-token: write
725+
steps:
726+
- name: Checkout
727+
uses: actions/checkout@v4
728+
with:
729+
fetch-depth: 0
730+
731+
- name: Authenticate to Google Cloud
732+
uses: google-github-actions/auth@v1
733+
with:
734+
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
735+
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
736+
737+
- name: Set up Google Cloud SDK
738+
uses: google-github-actions/setup-gcloud@v1
739+
740+
- name: Set up Flux CLI
741+
uses: fluxcd/flux2/action@main
742+
743+
- name: Get Cluster Credentials
744+
uses: "google-github-actions/get-gke-credentials@v1"
745+
with:
746+
cluster_name: dogfood-v2
747+
location: us-central1-a
748+
project_id: coder-dogfood-v2
749+
750+
- name: Reconcile Flux
751+
run: |
752+
set -euxo pipefail
753+
flux --namespace flux-system reconcile source git flux-system
754+
flux --namespace flux-system reconcile source git coder-main
755+
flux --namespace flux-system reconcile kustomization flux-system
756+
flux --namespace flux-system reconcile kustomization coder
757+
flux --namespace flux-system reconcile source chart coder-coder
758+
flux --namespace coder reconcile helmrelease coder
759+
760+
# Just updating Flux is usually not enough. The Helm release may get
761+
# redeployed, but unless something causes the Deployment to update the
762+
# pods won't be recreated. It's important that the pods get recreated,
763+
# since we use `imagePullPolicy: Always` to ensure we're running the
764+
# latest image.
765+
- name: Rollout Deployment
766+
run: |
767+
set -euxo pipefail
768+
kubectl --namespace coder rollout restart deployment/coder
769+
kubectl --namespace coder rollout status deployment/coder
770+
771+
deploy-wsproxies:
772+
runs-on: ubuntu-latest
773+
needs: build-main-image
774+
steps:
775+
- name: Checkout
776+
uses: actions/checkout@v4
777+
with:
778+
fetch-depth: 0
779+
780+
- name: Setup flyctl
781+
uses: superfly/flyctl-actions/setup-flyctl@master
782+
783+
- name: Deploy workspace proxies
784+
run: |
785+
flyctl deploy --image ghcr.io/coder/coder-preview:main --app paris-coder -y
786+
flyctl deploy --image ghcr.io/coder/coder-preview:main --app sydney-coder -y
787+
flyctl deploy --image ghcr.io/coder/coder-preview:main --app sao-paulo-coder -y
788+
env:
789+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
790+
791+
# TODO: when we remove this, instead of removing it we need to change it so it
792+
# still upgrades workspace proxies which are not deployed on K8s
793+
deploy-legacy:
794+
name: "deploy-legacy"
795+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
796+
timeout-minutes: 30
797+
needs: changes
798+
if: |
799+
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
800+
&& needs.changes.outputs.docs-only == 'false'
801+
permissions:
802+
contents: read
803+
id-token: write
804+
steps:
805+
- name: Checkout
806+
uses: actions/checkout@v4
807+
with:
808+
fetch-depth: 0
809+
810+
- name: Authenticate to Google Cloud
811+
uses: google-github-actions/auth@v1
812+
with:
813+
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
814+
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
815+
816+
- name: Set up Google Cloud SDK
817+
uses: google-github-actions/setup-gcloud@v1
818+
819+
- name: Setup Node
820+
uses: ./.github/actions/setup-node
821+
822+
- name: Setup Go
823+
uses: ./.github/actions/setup-go
824+
825+
- name: Install goimports
826+
run: go install golang.org/x/tools/cmd/goimports@latest
827+
- name: Install nfpm
828+
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
829+
830+
- name: Install zstd
831+
run: sudo apt-get install -y zstd
832+
833+
- name: Build Release
834+
run: |
835+
set -euo pipefail
836+
go mod download
837+
838+
version="$(./scripts/version.sh)"
839+
make gen/mark-fresh
840+
make -j \
841+
build/coder_"$version"_windows_amd64.zip \
842+
build/coder_"$version"_linux_amd64.{tar.gz,deb}
843+
844+
- name: Install Release
845+
run: |
846+
set -euo pipefail
847+
848+
regions=(
849+
# gcp-region-id instance-name systemd-service-name
850+
"us-central1-a coder coder"
851+
"australia-southeast1-b coder-sydney coder-workspace-proxy"
852+
"europe-west3-c coder-europe coder-workspace-proxy"
853+
"southamerica-east1-b coder-brazil coder-workspace-proxy"
854+
)
855+
856+
deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
857+
if [ ! -f "$deb_pkg" ]; then
858+
echo "deb package not found: $deb_pkg"
859+
ls -l ./build
860+
exit 1
861+
fi
862+
863+
gcloud config set project coder-dogfood
864+
for region in "${regions[@]}"; do
865+
echo "::group::$region"
866+
set -- $region
867+
868+
set -x
869+
gcloud config set compute/zone "$1"
870+
gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
871+
gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
872+
set +x
873+
874+
echo "::endgroup::"
875+
done

.github/workflows/typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ darcula = "darcula"
1414
Hashi = "Hashi"
1515
trialer = "trialer"
1616
encrypter = "encrypter"
17+
hel = "hel" # as in helsinki
1718

1819
[files]
1920
extend-exclude = [

cli/state.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ func (r *RootCmd) statePull() *clibase.Cmd {
4646
}
4747
build = workspace.LatestBuild
4848
} else {
49-
build, err = client.WorkspaceBuildByUsernameAndWorkspaceNameAndBuildNumber(inv.Context(), codersdk.Me, inv.Args[0], strconv.FormatInt(buildNumber, 10))
49+
owner, workspace, err := splitNamedWorkspace(inv.Args[0])
50+
if err != nil {
51+
return err
52+
}
53+
build, err = client.WorkspaceBuildByUsernameAndWorkspaceNameAndBuildNumber(inv.Context(), owner, workspace, strconv.FormatInt(buildNumber, 10))
5054
if err != nil {
5155
return err
5256
}

0 commit comments

Comments
 (0)