Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed May 23, 2020
1 parent 199d07a commit 8f1f5bd
Show file tree
Hide file tree
Showing 11 changed files with 4,078 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: deploy
on:
pull_request:
push:
branches: [master]

jobs:
build:
name: pr
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-python@v1
- run: pip install virtualenv
- run: make
- run: make push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist
/node_modules
/venv
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: check-json
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v7.0.0
hooks:
- id: eslint
args: [--fix]
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2020 Anthony Sottile

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: all
all: dist/index.js

venv: Makefile
rm -rf venv
virtualenv venv -ppython3
venv/bin/pip install markdown-to-presentation

node_modules: package.json
npm install --silent
test -d node_modules
touch node_modules

dist/index.js: index.js node_modules
node_modules/.bin/webpack --config webpack.config.js
# terrible hack to prevent lookup of `navigator`
# if someone knows the correct way to use webpack, PRs welcome!
sed -i 's/\bnavigator\b/({})/g' $@

.PHONY: push
push: venv
venv/bin/markdown-to-presentation push \
--pages-branch release \
README.md LICENSE action.yml dist/index.js
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[![Build Status](https://github.com/deadsnakes/action/workflows/deploy/badge.svg)](https://github.com/deadsnakes/action/actions)

deadsnakes/action
=================

a GitHub action to install (pre-release) pythons from [deadsnakes]

[deadsnakes]: https://github.com/deadsnakes

### using this action

To use this action, add it adjacent to `setup-python` and opt into it
conditionally. Here's an example which uses `python-version` as a matrix.

```yaml
on:
push:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9-dev]
name: main
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
if: matrix.python-version != '3.9-dev'
with:
python-version: ${{ matrix.python-version }}
- uses: deadsnakes/[email protected]
if: matrix.python-version == '3.9-dev'
with:
python-version: ${{ matrix.python-version }}
- run: python --version --version && which python
```
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: deadsnakes
description: install (pre-release) pythons from deadsnakes
inputs:
python-version:
description: python version to use, such as '3.9'
required: true
runs:
using: node12
main: dist/index.js
48 changes: 48 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const os = require('os');
const path = require('path');
const core = require('@actions/core');
const exec = require('@actions/exec');

async function main() {
let ppa, version = core.getInput('python-version');
const versionF = parseFloat(version);

if (version.endsWith('-dev')) {
version = version.replace(/-dev$/, '');
ppa = 'ppa:deadsnakes/nightly';
} else {
ppa = 'ppa:deadsnakes/ppa';
}

const py = `python${version}`;

// TODO: this is specific to bionic, when github actions switches to
// focal this will need to be updated!
let packages = [`${py}-dev`, `${py}-venv`];
if (versionF >= 3.9) {
packages.push(`${py}-distutils`);
} else {
packages.push('python3-distutils');
}

await core.group(`set up deadsnakes and install ${py}`, async () => {
await exec.exec('sudo', ['add-apt-repository', ppa]);
await exec.exec(
'sudo',
[
'apt-get', 'install', '-y', '--no-install-recommends',
...packages,
],
);
});

await core.group(`set up ${py} environment`, async () => {
const envdir = path.join(os.homedir(), `venv-${version}`);
await exec.exec(py, ['-mvenv', envdir]);
core.addPath(path.join(envdir, 'bin'));
const packages = ['pip', 'setuptools', 'wheel'];
await exec.exec('pip', ['install', '--upgrade', ...packages]);
});
}

main().catch((e) => core.setFailed(e.message));
Loading

0 comments on commit 8f1f5bd

Please sign in to comment.