From 22ecc2956659dc0c7a0fc71543f420d46d43b18c Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 10:08:10 +1000 Subject: [PATCH 1/7] Add GitHub actions for CI/testing --- .github/workflows/linux.yml | 40 +++++++++++++++++++++++++++ .github/workflows/linux_nightly.yml | 40 +++++++++++++++++++++++++++ .github/workflows/mac.yml | 40 +++++++++++++++++++++++++++ .github/workflows/mac_nightly.yml | 40 +++++++++++++++++++++++++++ .github/workflows/windows.yml | 40 +++++++++++++++++++++++++++ .github/workflows/windows_nightly.yml | 40 +++++++++++++++++++++++++++ 6 files changed, 240 insertions(+) create mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/linux_nightly.yml create mode 100644 .github/workflows/mac.yml create mode 100644 .github/workflows/mac_nightly.yml create mode 100644 .github/workflows/windows.yml create mode 100644 .github/workflows/windows_nightly.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..8b2fecc --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,40 @@ +name: Linux + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1" + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/linux_nightly.yml b/.github/workflows/linux_nightly.yml new file mode 100644 index 0000000..15005c0 --- /dev/null +++ b/.github/workflows/linux_nightly.yml @@ -0,0 +1,40 @@ +name: Linux nightly + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "nightly" + os: + - ubuntu-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml new file mode 100644 index 0000000..8bcfc02 --- /dev/null +++ b/.github/workflows/mac.yml @@ -0,0 +1,40 @@ +name: Mac OS X + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1" + os: + - macOS-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/mac_nightly.yml b/.github/workflows/mac_nightly.yml new file mode 100644 index 0000000..b21ac1a --- /dev/null +++ b/.github/workflows/mac_nightly.yml @@ -0,0 +1,40 @@ +name: Mac OS X nightly + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "nightly" + os: + - macOS-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..e875498 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,40 @@ +name: Windows + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "1" + os: + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows_nightly.yml b/.github/workflows/windows_nightly.yml new file mode 100644 index 0000000..5a104e5 --- /dev/null +++ b/.github/workflows/windows_nightly.yml @@ -0,0 +1,40 @@ +name: Windows nightly + +on: + - push + - pull_request + +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + version: + - "nightly" + os: + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - name: Cache artifacts + uses: actions/cache@v1 + env: + cache-name: cache-artifacts + with: + path: ~/.julia/artifacts + key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} + restore-keys: | + ${{ runner.os }}-test-${{ env.cache-name }}- + ${{ runner.os }}-test- + ${{ runner.os }}- + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + - uses: julia-actions/julia-uploadcodecov@latest + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 8245a05d13347d231923fc662205885fd8008c81 Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 10:10:39 +1000 Subject: [PATCH 2/7] Add badges to readme --- README.md | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 16ffb27..f6fe967 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,25 @@ ![Cover](pic/CMAP.png) +

+ + + + + + + + + + + + +

+ # cmap.jl CMAP.jl is the Julia client for Simons CMAP project. It provides access to the Simons CMAP database where various ocean data sets are hosted. These data sets include multi decades of remote sensing observations (satellite), numerical model estimates, and field expeditions. -This package is adopted from [pycmap](https://github.com/simonscmap/pycmap), which is the python client of Simons CMAP ecosystem. +This package is adopted from [pycmap](https://github.com/simonscmap/pycmap), which is the python client of Simons CMAP ecosystem. ## Documentation @@ -13,7 +28,7 @@ To be filled out. ## Usage example 1. Set your Simons API key. - + To make API requests, you need to get an API key from [Simons CMAP website](https://simonscmap.com). Once you have your API key, run the following command to store the API key on your local machine: ```julia @@ -27,20 +42,20 @@ To be filled out. datasets() ``` -1. Retrieve a subset of sea surface temperature measured by satellite. - +1. Retrieve a subset of sea surface temperature measured by satellite. + ```julia space_time( - table = "tblArgoMerge_REP", - variable = "argo_merge_salinity_adj", - dt1 = "2015-05-01", - dt2 = "2015-05-30", - lat1 = 28.1, - lat2 = 35.4, - lon1 = -71.3, - lon2 = -50, - depth1 = 0, + table = "tblArgoMerge_REP", + variable = "argo_merge_salinity_adj", + dt1 = "2015-05-01", + dt2 = "2015-05-30", + lat1 = 28.1, + lat2 = 35.4, + lon1 = -71.3, + lon2 = -50, + depth1 = 0, depth2 = 100 - ) + ) ``` From e73b29d37de19179f81f8e4b56ae705564f8b649 Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 10:30:35 +1000 Subject: [PATCH 3/7] Trying different approaches for CI --- .github/workflows/linux.yml | 2 ++ .github/workflows/mac.yml | 3 ++- src/rest.jl | 15 +++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8b2fecc..e89d910 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -35,6 +35,8 @@ jobs: ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + env: + API_KEY: ${{ secrets.API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 8bcfc02..856fc91 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -37,4 +37,5 @@ jobs: - uses: julia-actions/julia-runtest@latest - uses: julia-actions/julia-uploadcodecov@latest env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + API_KEY: ${{ secrets.API_KEY }} \ No newline at end of file diff --git a/src/rest.jl b/src/rest.jl index 885dc3c..5bf339a 100644 --- a/src/rest.jl +++ b/src/rest.jl @@ -72,10 +72,17 @@ get_api_key() """ function get_api_key() keyFile = api_key_fname() - if ~isfile(keyFile) - error("API Key file not found. The following command will register the API key:\n\nset_api_key(key::String)\n\n") - end - return DataFrame(CSV.File(keyFile))[1, 1] + if !isfile(keyFile) + error(""" + API Key file not found. The following command will register the API key: + + ``` + set_api_key("Your API Key here") + ``` + """) + else # Allow for environment variable secret API key for testing? + return get(ENV, "CMAP_API_KEY", DataFrame(CSV.File(keyFile))[1, 1]) + end end From ad07db69057d67496d3cd6f43f6d616ee301290b Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 10:36:33 +1000 Subject: [PATCH 4/7] Fix get_api_key() --- src/rest.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rest.jl b/src/rest.jl index 5bf339a..761bc83 100644 --- a/src/rest.jl +++ b/src/rest.jl @@ -72,7 +72,11 @@ get_api_key() """ function get_api_key() keyFile = api_key_fname() - if !isfile(keyFile) + if isfile(keyFile) + return DataFrame(CSV.File(keyFile))[1, 1] + else if haskey(ENV, "CMAP_API_KEY") + return ENV["CMAP_API_KEY"] + else error(""" API Key file not found. The following command will register the API key: @@ -80,8 +84,6 @@ function get_api_key() set_api_key("Your API Key here") ``` """) - else # Allow for environment variable secret API key for testing? - return get(ENV, "CMAP_API_KEY", DataFrame(CSV.File(keyFile))[1, 1]) end end From 5282c64678e119b6d255dfbf410892a94de9a221 Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 10:41:48 +1000 Subject: [PATCH 5/7] Fix typo in get_api_key() --- src/rest.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rest.jl b/src/rest.jl index 761bc83..88990ef 100644 --- a/src/rest.jl +++ b/src/rest.jl @@ -74,7 +74,7 @@ function get_api_key() keyFile = api_key_fname() if isfile(keyFile) return DataFrame(CSV.File(keyFile))[1, 1] - else if haskey(ENV, "CMAP_API_KEY") + elseif haskey(ENV, "CMAP_API_KEY") return ENV["CMAP_API_KEY"] else error(""" From 60a84b4a7fc81da0948a10b1276c6a8756965209 Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 10:53:34 +1000 Subject: [PATCH 6/7] Fix GH action typo --- .github/workflows/linux.yml | 2 +- .github/workflows/mac.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e89d910..f6824e5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -36,7 +36,7 @@ jobs: - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest env: - API_KEY: ${{ secrets.API_KEY }} + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 856fc91..72ebd34 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -38,4 +38,4 @@ jobs: - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - API_KEY: ${{ secrets.API_KEY }} \ No newline at end of file + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} \ No newline at end of file From 1af937b1fd176659fbdc436e8107d1ec4ef5c60c Mon Sep 17 00:00:00 2001 From: Benoit Pasquier Date: Thu, 23 Jul 2020 11:01:50 +1000 Subject: [PATCH 7/7] Fix GH actions! --- .github/workflows/linux_nightly.yml | 2 ++ .github/workflows/mac.yml | 5 +++-- .github/workflows/mac_nightly.yml | 2 ++ .github/workflows/windows.yml | 2 ++ .github/workflows/windows_nightly.yml | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux_nightly.yml b/.github/workflows/linux_nightly.yml index 15005c0..ccf09f7 100644 --- a/.github/workflows/linux_nightly.yml +++ b/.github/workflows/linux_nightly.yml @@ -35,6 +35,8 @@ jobs: ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 72ebd34..472f37f 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -35,7 +35,8 @@ jobs: ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} \ No newline at end of file + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/mac_nightly.yml b/.github/workflows/mac_nightly.yml index b21ac1a..2b935c5 100644 --- a/.github/workflows/mac_nightly.yml +++ b/.github/workflows/mac_nightly.yml @@ -35,6 +35,8 @@ jobs: ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e875498..cda0981 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -35,6 +35,8 @@ jobs: ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/windows_nightly.yml b/.github/workflows/windows_nightly.yml index 5a104e5..0e49b26 100644 --- a/.github/workflows/windows_nightly.yml +++ b/.github/workflows/windows_nightly.yml @@ -35,6 +35,8 @@ jobs: ${{ runner.os }}- - uses: julia-actions/julia-buildpkg@latest - uses: julia-actions/julia-runtest@latest + env: + CMAP_API_KEY: ${{ secrets.CMAP_API_KEY }} - uses: julia-actions/julia-uploadcodecov@latest env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}