Skip to content

Commit bec94db

Browse files
authored
[skip changelog] Sync install script with template (#1396)
* [skip changelog] Bring shell scripts into compliance with standard formatting A standardized style for all Arduino Tooling shell scripts has been established. The `.editorconfig` file is updated accordingly and all the repository's scripts made compliant with it. * [skip changelog] Sync install script with template We have assembled a collection of reusable project assets: https://github.com/arduino/tooling-project-assets These assets will be used in the repositories of all Arduino tooling projects. Some minor improvements and standardizations have been made in the upstream "template" installation script, and those are introduced to this repository via this pull request. Notable: - ShellCheck compliance - Support for specifying nightly build versions (e.g., "nightly-latest") via the script argument - Remove cryptic output not of interest to the user (likely forgotten debug artifacts from script development)
1 parent c4d39e3 commit bec94db

File tree

4 files changed

+236
-250
lines changed

4 files changed

+236
-250
lines changed

.editorconfig

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ indent_size = 4
1919
indent_style = space
2020
indent_size = 2
2121

22-
[*.sh]
23-
indent_style = tab
24-
indent_size = 4
22+
[*.{bash,sh}]
23+
indent_size = 2
24+
indent_style = space

.github/tools/fetch_athena_stats.sh

+24-22
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
set -euo pipefail
1616

17-
! read -r -d '' query << EOM
17+
! read -r -d '' query <<EOM
1818
select
1919
replace(url_extract_path("d.url"), '/arduino-cli/arduino-cli_', '') as flavor,
2020
count("id") as gauge
@@ -27,40 +27,42 @@ group by 1
2727
EOM
2828

2929
queryExecutionId=$(
30-
aws athena start-query-execution \
31-
--query-string "${query}" \
32-
--query-execution-context "Database=demo_books" \
33-
--result-configuration "OutputLocation=${AWS_ATHENA_OUTPUT_LOCATION}" \
34-
--region us-east-1 | jq -r ".QueryExecutionId"
30+
aws athena start-query-execution \
31+
--query-string "${query}" \
32+
--query-execution-context "Database=demo_books" \
33+
--result-configuration "OutputLocation=${AWS_ATHENA_OUTPUT_LOCATION}" \
34+
--region us-east-1 | jq -r ".QueryExecutionId"
3535
)
3636

3737
echo "QueryExecutionId is ${queryExecutionId}"
3838
for i in $(seq 1 120); do
39-
queryState=$( aws athena get-query-execution \
40-
--query-execution-id "${queryExecutionId}" \
41-
--region us-east-1 | jq -r ".QueryExecution.Status.State"
42-
);
39+
queryState=$(
40+
aws athena get-query-execution \
41+
--query-execution-id "${queryExecutionId}" \
42+
--region us-east-1 | jq -r ".QueryExecution.Status.State"
43+
)
4344

4445
if [[ "${queryState}" == "SUCCEEDED" ]]; then
45-
break;
46-
fi;
46+
break
47+
fi
4748

4849
echo "QueryExecutionId ${queryExecutionId} - state is ${queryState}"
4950

5051
if [[ "${queryState}" == "FAILED" ]]; then
51-
exit 1;
52-
fi;
52+
exit 1
53+
fi
5354

5455
sleep 2
5556
done
5657

5758
echo "Query succeeded. Processing data"
58-
queryResult=$( aws athena get-query-results \
59-
--query-execution-id "${queryExecutionId}" \
60-
--region us-east-1 | jq --compact-output
61-
);
59+
queryResult=$(
60+
aws athena get-query-results \
61+
--query-execution-id "${queryExecutionId}" \
62+
--region us-east-1 | jq --compact-output
63+
)
6264

63-
! read -r -d '' jsonTemplate << EOM
65+
! read -r -d '' jsonTemplate <<EOM
6466
{
6567
"type": "gauge",
6668
"name": "arduino.downloads.total",
@@ -78,8 +80,8 @@ EOM
7880

7981
datapoints="["
8082
for row in $(echo "${queryResult}" | jq 'del(.ResultSet.Rows[0])' | jq -r '.ResultSet.Rows[] | .Data' --compact-output); do
81-
value=$(jq -r ".[1].VarCharValue" <<< "${row}")
82-
tag=$(jq -r ".[0].VarCharValue" <<< "${row}")
83+
value=$(jq -r ".[1].VarCharValue" <<<"${row}")
84+
tag=$(jq -r ".[0].VarCharValue" <<<"${row}")
8385
# Some splitting to obtain 0.6.0, Windows, 32bit elements from string 0.6.0_Windows_32bit.zip
8486
split=($(echo "$tag" | tr '_' '\n'))
8587
if [[ ${#split[@]} -ne 3 ]]; then
@@ -90,4 +92,4 @@ for row in $(echo "${queryResult}" | jq 'del(.ResultSet.Rows[0])' | jq -r '.Resu
9092
done
9193
datapoints="${datapoints::-1}]"
9294

93-
echo "::set-output name=result::$(jq --compact-output <<< "${datapoints}")"
95+
echo "::set-output name=result::$(jq --compact-output <<<"${datapoints}")"

docs/installation.md

+44-59
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
### Install via Homebrew (macOS/Linux)
1+
<!-- Source: https://github.com/arduino/tooling-project-assets/blob/main/other/installation-script/installation.md -->
2+
3+
## Install via Homebrew (macOS/Linux)
24

35
The Arduino CLI is available as a Homebrew formula since version `0.5.0`:
46

@@ -7,34 +9,34 @@ brew update
79
brew install arduino-cli
810
```
911

10-
#### Command line completion
12+
### Command line completion
1113

1214
[Command line completion](command-line-completion.md#brew) files are already bundled in the homebrew installation.
1315

14-
### Use the install script
16+
## Use the install script
1517

16-
The script requires `sh`. This is always available on Linux and macOS. `sh` is not available by default on Windows. The
17-
script may be run on Windows by installing [Git for Windows], then running it from Git Bash.
18+
The script requires `sh`, which is always available on Linux and macOS. `sh` is not available by default on Windows. The
19+
script can be run on Windows by installing [Git for Windows](https://gitforwindows.org/), then running it from Git Bash.
1820

1921
This script will install the latest version of Arduino CLI to `$PWD/bin`:
2022

21-
```sh
23+
```
2224
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
2325
```
2426

2527
If you want to target a different directory, for example `~/local/bin`, set the `BINDIR` environment variable like this:
2628

27-
```sh
29+
```
2830
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/local/bin sh
2931
```
3032

3133
If you would like to use the `arduino-cli` command from any location, install Arduino CLI to a directory already in your
3234
`PATH` or add the Arduino CLI installation path to your `PATH` environment variable.
3335

34-
If you want to download a specific arduino-cli version, for example `0.9.0`, pass the version number as a parameter like
35-
this:
36+
If you want to download a specific Arduino CLI version, for example `0.9.0` or `nightly-latest`, pass the version number
37+
as a parameter like this:
3638

37-
```sh
39+
```
3840
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh -s 0.9.0
3941
```
4042

@@ -45,75 +47,58 @@ Pre-built binaries for all the supported platforms are available for download fr
4547
If you would like to use the `arduino-cli` command from any location, extract the downloaded file to a directory already
4648
in your `PATH` or add the Arduino CLI installation path to your `PATH` environment variable.
4749

48-
#### Latest packages
50+
#### Latest release
4951

50-
| Platform | | |
51-
| --------- | ------------------ | ------------------ |
52-
| Linux | [Linux 32 bit] | [Linux 64 bit] |
53-
| Linux ARM | [Linux ARM 32 bit] | [Linux ARM 64 bit] |
54-
| Windows | [Windows 32 bit] | [Windows 64 bit] |
55-
| Mac OSX | | [Mac OSX] |
52+
| Platform | | |
53+
| --------- | -------------------- | -------------------- |
54+
| Linux | [32 bit][linux32] | [64 bit][linux64] |
55+
| Linux ARM | [32 bit][linuxarm32] | [64 bit][linuxarm64] |
56+
| Windows | [32 bit][windows32] | [64 bit][windows64] |
57+
| macOS | | [64 bit][macos] |
5658

57-
[linux 64 bit]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz
58-
[linux 32 bit]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_32bit.tar.gz
59-
[linux arm 64 bit]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARM64.tar.gz
60-
[linux arm 32 bit]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARMv7.tar.gz
61-
[windows 64 bit]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip
62-
[windows 32 bit]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_32bit.zip
63-
[mac osx]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_macOS_64bit.tar.gz
59+
[linux64]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz
60+
[linux32]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_32bit.tar.gz
61+
[linuxarm64]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARM64.tar.gz
62+
[linuxarm32]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARMv7.tar.gz
63+
[windows64]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip
64+
[windows32]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_32bit.zip
65+
[macos]: https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_macOS_64bit.tar.gz
6466

6567
> **Deprecation notice**: links in the form
6668
> `http://downloads.arduino.cc/arduino-cli/arduino-cli-latest-<platform>.tar.bz2` won’t be further updated. That URL
6769
> will provide the version `0.3.7-alpha.preview`, regardless of further releases.
6870
6971
#### Previous versions
7072

71-
These are available from the [releases page](https://github.com/arduino/arduino-cli/releases)
73+
These are available from the "Assets" sections on the [releases page](https://github.com/arduino/arduino-cli/releases).
7274

7375
#### Nightly builds
7476

7577
These builds are generated every day at 01:00 GMT from the `master` branch and should be considered unstable. In order
7678
to get the latest nightly build available for the supported platform, use the following links:
7779

78-
| Platform | | |
79-
| --------- | -------------------------- | -------------------------- |
80-
| Linux | [Nightly Linux 32 bit] | [Nightly Linux 64 bit] |
81-
| Linux ARM | [Nightly Linux ARM 32 bit] | [Nightly Linux ARM 64 bit] |
82-
| Windows | [Nightly Windows 32 bit] | [Nightly Windows 64 bit] |
83-
| Mac OSX | | [Nightly Mac OSX] |
84-
85-
[nightly linux 64 bit]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_64bit.tar.gz
86-
[nightly linux 32 bit]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_32bit.tar.gz
87-
88-
<!-- prettier-ignore -->
89-
[nightly linux arm 64 bit]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_ARM64.tar.gz
90-
91-
<!-- prettier-ignore -->
92-
[nightly linux arm 32 bit]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_ARMv7.tar.gz
93-
[nightly windows 64 bit]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Windows_64bit.zip
94-
[nightly windows 32 bit]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Windows_32bit.zip
95-
[nightly mac osx]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_macOS_64bit.tar.gz
80+
| Platform | | |
81+
| --------- | ---------------------------- | ---------------------------- |
82+
| Linux | [32 bit][linux32-nightly] | [64 bit][linux64-nightly] |
83+
| Linux ARM | [32 bit][linuxarm32-nightly] | [64 bit][linuxarm64-nightly] |
84+
| Windows | [32 bit][windows32-nightly] | [64 bit][windows64-nightly] |
85+
| macOS | | [64 bit][macos-nightly] |
86+
87+
[linux64-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_64bit.tar.gz
88+
[linux32-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_32bit.tar.gz
89+
[linuxarm64-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_ARM64.tar.gz
90+
[linuxarm32-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_ARMv7.tar.gz
91+
[windows64-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Windows_64bit.zip
92+
[windows32-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Windows_32bit.zip
93+
[macos-nightly]: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_macOS_64bit.tar.gz
9694

9795
> These links return a `302: Found` response, redirecting to latest generated builds by replacing `latest` with the
98-
> latest available build date, using the format YYYYMMDD (i.e for 2019/Aug/06 `latest` is replaced with `20190806` )
96+
> latest available build date, using the format YYYYMMDD (i.e for 2019-08-06 `latest` is replaced with `20190806` )
9997
10098
Checksums for the nightly builds are available at
10199
`https://downloads.arduino.cc/arduino-cli/nightly/nightly-<DATE>-checksums.txt`
102100

103101
### Build from source
104102

105-
If you’re familiar with Golang or if you want to contribute to the project, you will probably build the `arduino-cli`
106-
locally with your Go toolchain. Please refer to the [CONTRIBUTING] document for setup instructions.
107-
108-
If you don’t have a working Golang environment or if you want to build `arduino-cli` targeting different platforms, you
109-
can use [Task][task-site] to get a binary directly from sources. From the project folder run:
110-
111-
```sh
112-
task dist:all
113-
```
114-
115-
Once the build is over, you will find a `./dist/` folder containing the packages built out of the current source tree.
116-
117-
[git for windows]: https://gitforwindows.org/
118-
[contributing]: CONTRIBUTING.md
119-
[task-site]: https://taskfile.dev/#/installation
103+
If you're familiar with Golang or if you want to contribute to the project, you will probably build Arduino CLI locally
104+
with your Go toolchain. See the ["How to contribute"](CONTRIBUTING.md#building-the-source-code) page for instructions.

0 commit comments

Comments
 (0)