Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Remove deploy and add Windows test to GH actions #1401

Merged
merged 2 commits into from
Jan 6, 2022
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
143 changes: 55 additions & 88 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: CI-Tests
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: CI

on:
push:
branches:
Expand All @@ -11,110 +15,73 @@ on:
- master
- dev


jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]

steps:
- name: checkout
- name: Checkout
uses: actions/checkout@v2
- name: get node
uses: actions/setup-node@v1

# Node 14 matches the version of Node used by VS Code when this was
# written, but it should be updated when VS Code updates its Node version.
# Node needs to be installed before OS-specific setup so that we can run
# the hash verification script.
- name: Use Node 14.x
uses: actions/setup-node@v2
with:
node-version: 11.x
- name: linux setup
node-version: 14.x

- name: Windows setup
if: ${{ matrix.os == 'windows-latest' }}
run: |
curl -LO https://downloads.arduino.cc/arduino-1.8.19-windows.zip
node build/checkHash.js arduino-1.8.19-windows.zip `
c704a821089eab2588f1deae775916219b1517febd1dd574ff29958dca873945
7z x arduino-1.8.19-windows.zip -o"$Env:TEMP\arduino-ide"
echo "$Env:TEMP\arduino-ide\arduino-1.8.19" | Out-File -FilePath $env:GITHUB_PATH -Append
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worthwhile to do a hash check on the download as well (like we're doing in the ADO pipeline)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can add it. If we're going to do it on all 3 platforms, it's probably best to extract the inline node script to a separate file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added for Linux and Windows. I'm leaving Mac alone for now because it installs through Homebrew. We could likely switch it to something closer to the Linux install, but I'll leave that for a future PR.

- name: Linux setup
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0
sleep 3
wget https://downloads.arduino.cc/arduino-1.8.2-linux64.tar.xz -P /home/$USER
tar -xvf /home/$USER/arduino-1.8.2-linux64.tar.xz -C /home/$USER/
sudo ln -s /home/$USER/arduino-1.8.2/arduino /usr/bin/arduino
wget https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz -P /home/$USER
node build/checkHash.js /home/$USER/arduino-1.8.19-linux64.tar.xz \
eb68bddc1d1c0120be2fca1350a03ee34531cf37f51847b21210b6e70545bc9b
tar -xvf /home/$USER/arduino-1.8.19-linux64.tar.xz -C /home/$USER/
sudo ln -s /home/$USER/arduino-1.8.19/arduino /usr/bin/arduino
sudo apt-get update
sudo apt-get install g++-multilib
sudo apt-get install -y build-essential
sudo apt-get install libudev-dev
- name: macos setup
sudo apt-get install -y g++-multilib build-essential libudev-dev
- name: macOS setup
if: ${{ matrix.os == 'macos-latest' }}
run: |
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install arduino --cask
- name: preinstall
run: |
npm install -g node-gyp
npm install -g vsce@"^1.0.0"
npm install -g gulp
- name: install
run: npm install
- name: scripts
run: |
gulp tslint
vsce package
- name: run tests

# Windows agents already have gulp installed.
- name: Install gulp
if: ${{ matrix.os != 'windows-latest' }}
run: npm install --global gulp
- name: Install global dependencies
run: npm install --global node-gyp vsce
- name: Install project dependencies
run: npm install

- name: Check for linting errors
run: gulp tslint
- name: Build and pack extension
run: vsce package --out vscode-arduino.vsix
- name: Publish extension VSIX as artifact
uses: actions/upload-artifact@v2
with:
name: VS Code extension VSIX (${{ matrix.os }})
path: vscode-arduino.vsix

- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
run: npm test --silent

deploy:
needs: build
runs-on: ubuntu-latest
environment: vsix-publishing
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- run: echo ${{env.VERSION}}
- name: Checkout
uses: actions/checkout@v2
- name: get node
uses: actions/setup-node@v1
with:
node-version: 11.x
- name: linux setup
run: |
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0
sleep 3
sudo apt-get update
sudo apt-get install g++-multilib
sudo apt-get install -y build-essential
sudo apt-get install libudev-dev
- name: preinstall
run: |
npm install -g node-gyp
npm install -g vsce@"^1.0.0"
npm install -g gulp
- name: install
run: npm install
- name: scripts
run: |
gulp tslint
gulp genAikey
vsce package
- name: upload .vsix to github tag
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.OAUTH_TOKEN }}
file: ${{github.workspace}}/vscode-arduino*.vsix
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: check for production tag
id: check-version
run: |
if [[ ${{ env.VERSION }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=ISPRODUCTION::true
fi
# Skip attempting to publish for now, because I can't figure out how to
# generate a valid VSCE_TOKEN. Instead we can manually publish by uploading
# the release build artifact to the extension publisher site.
- name: publish
if: false && steps.check-version.outputs.ISPRODUCTION == 'true'
env:
PROD_AIKEY: ${{ secrets.PROD_AIKEY }}
run: |
gulp genAikey
vsce publish -p ${{ secrets.VSCE_TOKEN }}
6 changes: 2 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ steps:
- script: curl -LO https://downloads.arduino.cc/arduino-1.8.19-windows.zip
displayName: Download Arduino IDE
- script: >-
node --eval "process.exit(require('crypto').createHash('sha256').update(
require('fs').readFileSync('arduino-1.8.19-windows.zip')).digest('hex')
== 'c704a821089eab2588f1deae775916219b1517febd1dd574ff29958dca873945'
? 0 : 1)"
node build/checkHash.js arduino-1.8.19-windows.zip
c704a821089eab2588f1deae775916219b1517febd1dd574ff29958dca873945
displayName: Verify Arduino IDE
- task: ExtractFiles@1
displayName: Extract Arduino IDE
Expand Down
17 changes: 17 additions & 0 deletions build/checkHash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Usage
// $ node checkHash.js myfile.zip c704...3945
// Returns with an exit code of zero if and only if the SHA-256 hash of the
// given file matches the expected hash.

const path = process.argv[2];
const expected = process.argv[3];
const data = require('fs').readFileSync(path);
const hash = require('crypto').createHash('sha256').update(data).digest('hex');
if (hash !== expected) {
console.error(
`Expected SHA-256 of "${path}" to be ${expected} but found ${hash}.`);
process.exit(1);
}