Skip to content

Check if the build exists before starting an instance #1230

Check if the build exists before starting an instance

Check if the build exists before starting an instance #1230

Workflow file for this run

name: Build
on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
workflow_dispatch:
env:
IMAGE_VERSION: "0.2"
jobs:
python-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Run isort
uses: isort/isort-action@master
with:
isort-version: 5.12.0
configuration: "--settings-file pyconfig.toml --check-only --diff"
sort-paths: "cli"
- name: Run black
uses: psf/black@stable
with:
options: "--config pyconfig.toml --check --verbose"
src: "./cli"
version: "~= 22.0"
cli-test-master:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
python-version: [ 3.7, 3.8, 3.9, "3.10", 3.11 ]
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_dev.txt
- name: Run pytest
run: |
mkdir -p dstack/_internal/hub/statics
pytest tests/ --ignore=tests/integration/
build-hub-master:
runs-on: ubuntu-latest
defaults:
run:
working-directory: hub
steps:
- uses: actions/checkout@v3
- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install packages
run: npm install
- name: Build dist
run: npm run build
- name: Upload dist
uses: actions/upload-artifact@v1
with:
name: hub-dist
path: hub/build
cli-upload-master:
runs-on: ubuntu-latest
needs:
- cli-test-master
- build-hub-master
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Download hub dist
uses: actions/download-artifact@v1
with:
name: hub-dist
- name: Copy hub dist
run: |
mkdir -p cli/dstack/_internal/hub/statics
cp -a hub-dist/** cli/dstack/_internal/hub/statics
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r cli/requirements.txt
pip install wheel twine
- name: Upload pip package
run: |
VERSION=$((${{ github.run_number }} + 150))
echo "__version__ = \"$VERSION\"" > cli/dstack/version.py
echo "__is_release__ = False" >> cli/dstack/version.py
echo "miniforge_image = \"${{ env.IMAGE_VERSION }}\"" >> cli/dstack/version.py
cp README.md cli
python setup.py sdist bdist_wheel
python -m twine upload --repository testpypi --username ${{ secrets.TESTPYPI_USERNAME }} --password ${{ secrets.TESTPYPI_PASSWORD }} dist/*
update-get-dstack-master:
runs-on: ubuntu-latest
needs:
- cli-upload-master
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Install AWS
run: pip install awscli
- run: |
VERSION=$((${{ github.run_number }} + 150))
echo $VERSION | aws s3 cp - s3://get-dstack/stgn-cli/latest-version --acl public-read
runner-test-master:
defaults:
run:
working-directory: runner
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
args: --issues-exit-code=0 --timeout=20m
working-directory: runner
- name: Test
run: |
go version
go fmt $(go list ./... | grep -v /vendor/)
go vet $(go list ./... | grep -v /vendor/)
go test -race $(go list ./... | grep -v /vendor/)
runner-compile-master:
defaults:
run:
working-directory: runner
env:
REPO_NAME: github.com/dstackai/dstack
strategy:
matrix:
include:
- {goos: "linux", goarch: "386", runson: "ubuntu-latest"}
- {goos: "linux", goarch: "amd64", runson: "ubuntu-latest"}
- {goos: "windows", goarch: "amd64", runson: "ubuntu-latest"}
- {goos: "darwin", goarch: "amd64", runson: "macos-latest"}
- {goos: "darwin", goarch: "arm64", runson: "macos-latest"}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
ACTIONSOS: ${{ matrix.runson }}
run: |
VERSION=$((${{ github.run_number }} + 150))
go build -ldflags "-X '$REPO_NAME/runner/version.Version=$VERSION' -X '$REPO_NAME/runner/pkg/log.CloudLog=true' -extldflags '-static'" -o dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: actions/upload-artifact@v2
with:
name: dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }}
path: runner/dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }}
runner-upload-master:
defaults:
run:
working-directory: runner
needs: [ runner-compile-master ]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
strategy:
matrix:
include:
- {goos: "linux", goarch: "386", runson: "ubuntu-latest", platform: "x86", extension: ""}
- {goos: "linux", goarch: "amd64", runson: "ubuntu-latest", platform: "amd64", extension: ""}
- {goos: "windows", goarch: "amd64", runson: "ubuntu-latest", platform: "amd64", extension: ".exe"}
- {goos: "darwin", goarch: "amd64", runson: "macos-latest", platform: "amd64", extension: ""}
- {goos: "darwin", goarch: "arm64", runson: "macos-latest", platform: "arm64", extension: ""}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install AWS
run: pip install awscli
- name: Download Runner
uses: actions/download-artifact@v1
with:
name: dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }}
path: runner
- name: Upload to S3
run: |
VERSION=$((${{ github.run_number }} + 150))
aws s3 cp dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }} "s3://dstack-runner-downloads-stgn/$VERSION/binaries/dstack-runner-${{ matrix.goos }}-${{ matrix.platform }}${{ matrix.extension }}" --acl public-read
aws s3 cp dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }} "s3://dstack-runner-downloads-stgn/latest/binaries/dstack-runner-${{ matrix.goos }}-${{ matrix.platform }}${{ matrix.extension }}" --acl public-read
# cli-integration-tests:
# needs: [ runner-upload-master ]
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ ubuntu-latest ]
# python-version: [ 3.7, 3.8, 3.9, "3.10", 3.11 ]
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -e .
# pip install -r cli/requirements_dev.txt
# - name: Prepare hub
# run: |
# mkdir -p cli/dstack/_internal/hub/statics
# touch cli/dstack/_internal/hub/statics/index.html
# - name: Run pytest
# run: |
# pytest cli/tests/integration/