Skip to content

Commit

Permalink
Download dvc from official website (#40)
Browse files Browse the repository at this point in the history
* Download dvc from official website.

* Use dvc 2.18.0 in tests.

* closes: #39

* allow fallback to GH releases

* include mac in fallback

* debug

* debug

* debug

* debug

* error for non-200 status

* tweak check matrix

* debug

* probably not valid syntax?

* also probably not valid syntax?

* probably valid syntax

* cleanup

* verbal review comments

* update test actions

* simpifly with test cmd

* rm fail-fast

* backward test logic

Co-authored-by: Daniel Barnes <[email protected]>
  • Loading branch information
tasdomas and dacbd authored Oct 11, 2022
1 parent 7d95bc2 commit 10b2daa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check DVC GitHub Action
on:
schedule:
- cron: 0 0 * * *
- cron: '0 0 * * *' # everyday @ 0000 UTC
pull_request:
jobs:
verify:
Expand All @@ -22,39 +22,40 @@ jobs:
- ubuntu-latest
- macos-latest
- windows-latest
version:
- '1.0.1'
- '2.18.1'
include:
- system: ubuntu-18.04
container: ubuntu:18.04
version: '1.0.1'
- system: ubuntu-18.04
container: ubuntu:18.04
version: '2.18.1'
runs-on: ${{ matrix.system }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
if: matrix.container == 'ubuntu:18.04'
with:
node-version: '16'
- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
if: matrix.system == 'windows'
with:
python-version: '3.x'
- run: npm ci
- run: npm run lint
- run: npm run test
- name: local action with '1.0.1'
- name: local action with ${{ matrix.version }}
uses: ./
with:
version: '1.0.1'
version: ${{ matrix.version }}
- name: test DVC specific version
run: |
DVC_VER=$(dvc --version)
if [ $DVC_VER != '1.0.1' ]; then
exit 1
fi
test "$(dvc --version)" == "${{ matrix.version}}"
- name: local action with defaults
uses: ./
- name: test DVC latest version
run: |
DVC_VER=$(dvc --version)
if [ $DVC_VER == '1.0.1' ]; then
exit 1
fi
test "$(dvc --version)" != "${{ matrix.version}}"
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

31 changes: 22 additions & 9 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const download = async (url, path) => {
const res = await fetch(url);
const fileStream = fs.createWriteStream(path);
await new Promise((resolve, reject) => {
if (res.status !== 200) return reject(new Error(res.statusText));
res.body.pipe(fileStream);
res.body.on('error', err => {
reject(err);
Expand Down Expand Up @@ -51,11 +52,16 @@ const setupDVC = async opts => {
try {
sudo = await exec('which sudo');
} catch (err) {}

await download(
`https://github.com/iterative/dvc/releases/download/${version}/dvc_${version}_amd64.deb`,
'dvc.deb'
);
try {
const dvcURL = `https://dvc.org/download/linux-deb/dvc-${version}`;
console.log(`Installing DVC from: ${dvcURL}`);
await download(dvcURL, 'dvc.deb');
} catch (err) {
console.log('DVC Download Failed, trying from GitHub Releases');
const dvcURL = `https://github.com/iterative/dvc/releases/download/${version}/dvc_${version}_amd64.deb`;
console.log(`Installing DVC from: ${dvcURL}`);
await download(dvcURL, 'dvc.deb');
}
console.log(
await exec(
`${sudo} apt update && ${sudo} apt install -y --allow-downgrades git ./dvc.deb && ${sudo} rm -f 'dvc.deb'`
Expand All @@ -64,16 +70,23 @@ const setupDVC = async opts => {
}

if (platform === 'darwin') {
await download(
`https://github.com/iterative/dvc/releases/download/${version}/dvc-${version}.pkg`,
'dvc.pkg'
);
try {
const dvcURL = `https://dvc.org/download/osx/dvc-${version}`;
console.log(`Installing DVC from: ${dvcURL}`);
await download(dvcURL, 'dvc.pkg');
} catch (err) {
console.log('DVC Download Failed, trying from GitHub Releases');
const dvcURL = `https://github.com/iterative/dvc/releases/download/${version}/dvc-${version}.pkg`;
console.log(`Installing DVC from: ${dvcURL}`);
await download(dvcURL, 'dvc.pkg');
}
console.log(
await exec(`sudo installer -pkg "dvc.pkg" -target / && rm -f "dvc.pkg"`)
);
}

if (platform === 'win32') {
console.log('Installing DVC with pip');
console.log(
await exec(
`pip install --upgrade dvc[all]${
Expand Down

0 comments on commit 10b2daa

Please sign in to comment.