Skip to content

Commit

Permalink
Add warning to master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed May 26, 2022
1 parent e81abac commit e485e19
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 51 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/caching-envs-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: anaconda-client-env
use-mamba: true
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: anaconda-client-env
use-mamba: true

- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
Expand All @@ -41,12 +41,18 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('etc/example-environment-caching.yml') }}-${{ env.CACHE_NUMBER }}
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('etc/example-environment-caching.yml') }}-${{
env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache

- name: Update environment
run: mamba env update -n anaconda-client-env -f etc/example-environment-caching.yml
run:
mamba env update -n anaconda-client-env -f
etc/example-environment-caching.yml
if: steps.cache.outputs.cache-hit != 'true'
89 changes: 47 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ possibility of automatically activating the `test` environment on all shells.
> Each of the examples below is discussed in a dedicated section below.
| Documentation | Workflow Status |
| ----------------------------------------------- | ----------------------------------------------------------------|
| ----------------------------------------------- | --------------------------------------------------------------- |
| [Basic usage](#example-1-basic-usage) | [![Basic Usage Status][ex1-badge]][ex1] |
| [Other shells](#example-2-other-shells) | [![Other Shells Status][ex2-badge]][ex2] |
| [Other options](#example-3-other-options) | [![Other Options Status][ex3-badge]][ex3] |
Expand Down Expand Up @@ -575,61 +575,66 @@ as they are not included in the conda package cache.

### Caching environments

The first installation step should setup a Miniconda variant without
specifying a environment file.
The first installation step should setup a Miniconda variant without specifying
a environment file.

```yaml
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: anaconda-client-env
use-mamba: true
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: anaconda-client-env
use-mamba: true
```

It's a good idea to refresh the cache every 24 hours to avoid inconsistencies
of package versions between the CI pipeline and local installations.
Here we ensure that this happens by adding the current date to the cache key.
You can remove the "Get Date" step below if you use a resolved environment file product of
It's a good idea to refresh the cache every 24 hours to avoid inconsistencies of
package versions between the CI pipeline and local installations. Here we ensure
that this happens by adding the current date to the cache key. You can remove
the "Get Date" step below if you use a resolved environment file product of
`conda env export` or `conda list --explicit`.

```yaml
- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash
- name: Get Date
id: get-date
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')"
shell: bash
- name: Cache Conda env
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('etc/example-environment-caching.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache
- name: Cache Conda env
uses: actions/cache@v2
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{
steps.get-date.outputs.today }}-${{
hashFiles('etc/example-environment-caching.yml') }}-${{ env.CACHE_NUMBER
}}
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
id: cache
```

Keep in mind that hashing `etc/example-environment-caching.yml` is not the
same as hashing a resolved environment file. `conda` (and `mamba`) resolves
the dependencies declared in the YAML file according to the packages
available on the channels at installation time. Since packages are updated
all the time, you will not see these changes reflected in the cache until
the key gets updated by date.
Keep in mind that hashing `etc/example-environment-caching.yml` is not the same
as hashing a resolved environment file. `conda` (and `mamba`) resolves the
dependencies declared in the YAML file according to the packages available on
the channels at installation time. Since packages are updated all the time, you
will not see these changes reflected in the cache until the key gets updated by
date.

**This means that the same environment file can make your tests pass locally
but fail on CI, or the other way around. In that case, reset the cache
manually to see if that leads to consistent results, or use a resolved
environment file.**
**This means that the same environment file can make your tests pass locally but
fail on CI, or the other way around. In that case, reset the cache manually to
see if that leads to consistent results, or use a resolved environment file.**

Finally, update the environment based on the environment file if the cache
does not exist.
Finally, update the environment based on the environment file if the cache does
not exist.

```yaml
- name: Update environment
run: mamba env update -n anaconda-client-env -f etc/example-environment-caching.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Update environment
run:
mamba env update -n anaconda-client-env -f
etc/example-environment-caching.yml
if: steps.cache.outputs.cache-hit != 'true'
```

### Use a default shell
Expand Down
10 changes: 9 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20561,6 +20561,7 @@ function setupMiniconda(inputs) {
mambaInInstaller: false,
condaConfig: Object.assign({}, inputs.condaConfig),
};
// Warn about the deprecation of the master branch
yield core.group(`Creating bootstrap condarc file in ${constants.CONDARC_PATH}...`, conda.bootstrapConfig);
const installerInfo = yield core.group("Ensuring installer...", () => installer.getLocalInstallerPath(inputs, options));
// The desired installer may change the options
Expand Down Expand Up @@ -20607,6 +20608,13 @@ function setupMiniconda(inputs) {
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
core.warning(`
The 'master' branch is deprecated and will be removed from the repository in the future.

Please ensure your action is using the latest version, or point it to the 'main' branch.

"conda-incubator/setup-minicando@main"
`);
const inputs = yield core.group("Gathering Inputs...", input.parseInputs);
yield setupMiniconda(inputs);
}
Expand Down Expand Up @@ -30000,7 +30008,7 @@ module.exports.safeLoad = safeLoad;
/* 771 */
/***/ (function(module) {

module.exports = {"_args":[["[email protected]","/home/weg/projects/actions/setup-miniconda"]],"_from":"[email protected]","_id":"[email protected]","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"[email protected]","name":"cheerio","escapedName":"cheerio","rawSpec":"1.0.0-rc.3","saveSpec":null,"fetchSpec":"1.0.0-rc.3"},"_requiredBy":["/get-hrefs"],"_resolved":"https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz","_spec":"1.0.0-rc.3","_where":"/home/weg/projects/actions/setup-miniconda","author":{"name":"Matt Mueller","email":"[email protected]","url":"mat.io"},"bugs":{"url":"https://github.com/cheeriojs/cheerio/issues"},"dependencies":{"css-select":"~1.2.0","dom-serializer":"~0.1.1","entities":"~1.1.1","htmlparser2":"^3.9.1","lodash":"^4.15.0","parse5":"^3.0.1"},"description":"Tiny, fast, and elegant implementation of core jQuery designed specifically for the server","devDependencies":{"benchmark":"^2.1.0","coveralls":"^2.11.9","expect.js":"~0.3.1","istanbul":"^0.4.3","jquery":"^3.0.0","jsdom":"^9.2.1","jshint":"^2.9.2","mocha":"^3.1.2","xyz":"~1.1.0"},"engines":{"node":">= 0.6"},"files":["index.js","lib"],"homepage":"https://github.com/cheeriojs/cheerio#readme","keywords":["htmlparser","jquery","selector","scraper","parser","html"],"license":"MIT","main":"./index.js","name":"cheerio","repository":{"type":"git","url":"git://github.com/cheeriojs/cheerio.git"},"scripts":{"test":"make test"},"version":"1.0.0-rc.3"};
module.exports = {"_args":[["[email protected]","/Users/gpenacastellanos/Dropbox (Personal)/develop/conda-incubator/setup-miniconda"]],"_from":"[email protected]","_id":"[email protected]","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"[email protected]","name":"cheerio","escapedName":"cheerio","rawSpec":"1.0.0-rc.3","saveSpec":null,"fetchSpec":"1.0.0-rc.3"},"_requiredBy":["/get-hrefs"],"_resolved":"https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz","_spec":"1.0.0-rc.3","_where":"/Users/gpenacastellanos/Dropbox (Personal)/develop/conda-incubator/setup-miniconda","author":{"name":"Matt Mueller","email":"[email protected]","url":"mat.io"},"bugs":{"url":"https://github.com/cheeriojs/cheerio/issues"},"dependencies":{"css-select":"~1.2.0","dom-serializer":"~0.1.1","entities":"~1.1.1","htmlparser2":"^3.9.1","lodash":"^4.15.0","parse5":"^3.0.1"},"description":"Tiny, fast, and elegant implementation of core jQuery designed specifically for the server","devDependencies":{"benchmark":"^2.1.0","coveralls":"^2.11.9","expect.js":"~0.3.1","istanbul":"^0.4.3","jquery":"^3.0.0","jsdom":"^9.2.1","jshint":"^2.9.2","mocha":"^3.1.2","xyz":"~1.1.0"},"engines":{"node":">= 0.6"},"files":["index.js","lib"],"homepage":"https://github.com/cheeriojs/cheerio#readme","keywords":["htmlparser","jquery","selector","scraper","parser","html"],"license":"MIT","main":"./index.js","name":"cheerio","repository":{"type":"git","url":"git://github.com/cheeriojs/cheerio.git"},"scripts":{"test":"make test"},"version":"1.0.0-rc.3"};

/***/ }),
/* 772 */
Expand Down
9 changes: 8 additions & 1 deletion src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise<void> {
mambaInInstaller: false,
condaConfig: { ...inputs.condaConfig },
};

// Warn about the deprecation of the master branch
await core.group(
`Creating bootstrap condarc file in ${constants.CONDARC_PATH}...`,
conda.bootstrapConfig
Expand Down Expand Up @@ -110,6 +110,13 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise<void> {
*/
async function run(): Promise<void> {
try {
core.warning(`
The 'master' branch is deprecated and will be removed from the repository in the future.
Please ensure your action is using the latest version, or point it to the 'main' branch.
"conda-incubator/setup-minicando@main"
`);
const inputs = await core.group("Gathering Inputs...", input.parseInputs);
await setupMiniconda(inputs);
} catch (err) {
Expand Down

0 comments on commit e485e19

Please sign in to comment.