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 496feea
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 51 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/caching-envs-example.yml
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
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
60 changes: 58 additions & 2 deletions dist/setup/index.js
Expand Up @@ -6483,7 +6483,59 @@ exports.updatePython = {

/***/ }),
/* 114 */,
/* 115 */,
/* 115 */
/***/ (function(__unusedmodule, exports, __webpack_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.warnBranchChange = void 0;
const core = __importStar(__webpack_require__(470));
/**
* Warn about deprecation of master branch
*/
function warnBranchChange() {
return __awaiter(this, void 0, void 0, function* () {
core.warning(`
The master branch is deprecated and will be removed in a future release.

Please change your action to use the latest version, or point to the main branch.
conda-incubator/setup-minicando@main
`);
});
}
exports.warnBranchChange = warnBranchChange;


/***/ }),
/* 116 */,
/* 117 */,
/* 118 */
Expand Down Expand Up @@ -20548,6 +20600,7 @@ const input = __importStar(__webpack_require__(265));
const outputs = __importStar(__webpack_require__(405));
const installer = __importStar(__webpack_require__(555));
const conda = __importStar(__webpack_require__(259));
const warnings = __importStar(__webpack_require__(115));
const env = __importStar(__webpack_require__(956));
const baseTools = __importStar(__webpack_require__(49));
/**
Expand All @@ -20561,6 +20614,9 @@ function setupMiniconda(inputs) {
mambaInInstaller: false,
condaConfig: Object.assign({}, inputs.condaConfig),
};
// Warn about the deprecation of the master branch
yield core.group(`Deprecation warning!`, warnings.warnBranchChange);
core.warning("myInput was not set");
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 @@ -30000,7 +30056,7 @@ module.exports.safeLoad = safeLoad;
/* 771 */
/***/ (function(module) {

module.exports = {"_args":[["cheerio@1.0.0-rc.3","/home/weg/projects/actions/setup-miniconda"]],"_from":"cheerio@1.0.0-rc.3","_id":"cheerio@1.0.0-rc.3","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"cheerio@1.0.0-rc.3","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":"mattmuelle@gmail.com","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":[["cheerio@1.0.0-rc.3","/Users/gpenacastellanos/Dropbox (Personal)/develop/conda-incubator/setup-miniconda"]],"_from":"cheerio@1.0.0-rc.3","_id":"cheerio@1.0.0-rc.3","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"cheerio@1.0.0-rc.3","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":"mattmuelle@gmail.com","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
4 changes: 4 additions & 0 deletions src/setup.ts
Expand Up @@ -8,6 +8,7 @@ import * as input from "./input";
import * as outputs from "./outputs";
import * as installer from "./installer";
import * as conda from "./conda";
import * as warnings from "./warnings";
import * as env from "./env";
import * as baseTools from "./base-tools";

Expand All @@ -21,7 +22,10 @@ async function setupMiniconda(inputs: types.IActionInputs): Promise<void> {
mambaInInstaller: false,
condaConfig: { ...inputs.condaConfig },
};
// Warn about the deprecation of the master branch
await core.group(`Deprecation warning!`, warnings.warnBranchChange);

core.warning("myInput was not set");
await core.group(
`Creating bootstrap condarc file in ${constants.CONDARC_PATH}...`,
conda.bootstrapConfig
Expand Down
15 changes: 15 additions & 0 deletions src/warnings.ts
@@ -0,0 +1,15 @@
import * as core from "@actions/core";

/**
* Warn about deprecation of master branch
*/
export async function warnBranchChange(): Promise<void> {
core.warning(
`
The master branch is deprecated and will be removed in a future release.
Please change your action to use the latest version, or point to the main branch.
conda-incubator/setup-minicando@main
`
);
}

0 comments on commit 496feea

Please sign in to comment.