Skip to content

Commit

Permalink
Merge pull request #15 from HaydenMacDonald/lang-bug
Browse files Browse the repository at this point in the history
Replace linguist-action with setup-enry-action
  • Loading branch information
HaydenMacDonald authored May 16, 2022
2 parents 72c7894 + 19d05c1 commit 603e5ad
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 23 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/multigitminder.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: multigitminder
on:
push:
branches: [ main ]
branches: [ main, lang-bug ]
issues:
types: [ closed ]

Expand All @@ -19,11 +19,19 @@ jobs:
with:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLOSE_ISSUES: false
# Enry
- name: Setup Enry
uses: fabasoad/[email protected]
- name: Run Enry
id: enry
run: echo ::set-output name=languages::"{$(enry | sed 's/^\(.*\)\t\(.*\)$/\"\2\":\"\1\"/' | paste -sd "," -)}"
# multigitminder
- name: multigitminder
uses: HaydenMacDonald/[email protected]
id: multigitminder
with:
USERNAME: ${{ secrets.BEEMINDER_USERNAME }}
AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
GOAL: multigitminder
GOAL: python
TARGET_LANGS: Python ## e.g. "['python', 'dockerfile', 'javascript']" or simply Python
REPO_LANGS: ${{ steps.enry.outputs.languages }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/venv
.idea
.idea
mock_test.py
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.0
15 changes: 15 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "*"
setuptools = "*"
pyminder = "*"
"ruamel.yaml" = "*"

[dev-packages]

[requires]
python_version = "3.9"
122 changes: 122 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Optional
- `VALUE` - Value of data point as string (default value of '1').
- `COMMENT` - Comment about the data point (default: '[branch]@[commit-ref] via multigitminder API call').
- `TARGET_LANGS` - List of target languages, formatted as a stringified array/list (e.g. `"['python', 'javascript']"`)
- `REPO_LANGS` - List of languages inputted by [fabasoad/linguist-action](https://github.com/marketplace/actions/linguist-action).
- `REPO_LANGS` - List of languages inputted by [fabasoad/setup-enry-action](https://github.com/marketplace/actions/setup-enry).

## Outputs
- Print statement confirming the value, goal, and comment of data point sent to Beeminder.
Expand Down Expand Up @@ -122,7 +122,7 @@ and include `[multigitminder]` in the commit message of the commits you want to

### What if I want repositories with specific languages contributing to my Beeminder goal?

Use [actions/checkout@v2](https://github.com/actions/checkout) and [fabasoad/linguist-action](https://github.com/marketplace/actions/linguist-action) in the steps preceding `multigitminder` in your workflow file. Then add `linguist-action`'s output data and a list with your target language(s) as inputs for multigitminder (see below).
Use [actions/checkout@v2](https://github.com/actions/checkout) and [fabasoad/setup-enry-action](https://github.com/marketplace/actions/setup-enry) in the steps preceding `multigitminder` in your workflow file. Then add `setup-enry-action`'s output data and a list with your target language(s) as inputs for multigitminder (see below).

```yaml:examples/multigitminder-linguist.yml
name: multigitminder-linguist
Expand All @@ -138,13 +138,12 @@ jobs:
# Checkout
- name: Checkout
uses: actions/checkout@v2
# linguist
- name: Linguist Action
uses: fabasoad/[email protected]
id: linguist
with:
path: './'
percentage: true
# Enry
- name: Setup Enry
uses: fabasoad/[email protected]
- name: Run Enry
id: enry
run: echo ::set-output name=languages::"{$(enry | sed 's/^\(.*\)\t\(.*\)$/\"\2\":\"\1\"/' | paste -sd "," -)}"
# multigitminder
- name: multigitminder
uses: HaydenMacDonald/[email protected]
Expand All @@ -154,7 +153,7 @@ jobs:
AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
GOAL: YOUR_GOAL_NAME_HERE
TARGET_LANGS: YOUR_TARGET_LANGUAGES_HERE ## e.g. "['python', 'dockerfile', 'javascript']" or simply Python
REPO_LANGS: ${{ steps.linguist.outputs.data }}
REPO_LANGS: ${{ steps.enry.outputs.languages }}
```

Expand Down
Empty file added __init__.py
Empty file.
15 changes: 7 additions & 8 deletions examples/multigitminder-linguist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ jobs:
# Checkout
- name: Checkout
uses: actions/checkout@v2
# linguist
- name: Linguist Action
uses: fabasoad/[email protected]
id: linguist
with:
path: './'
percentage: true
# Enry
- name: Setup Enry
uses: fabasoad/[email protected]
- name: Run Enry
id: enry
run: echo ::set-output name=languages::"{$(enry | sed 's/^\(.*\)\t\(.*\)$/\"\2\":\"\1\"/' | paste -sd "," -)}"
# multigitminder
- name: multigitminder
uses: HaydenMacDonald/[email protected]
Expand All @@ -27,4 +26,4 @@ jobs:
AUTH_TOKEN: ${{ secrets.BEEMINDER_AUTH_TOKEN }}
GOAL: YOUR_GOAL_NAME_HERE
TARGET_LANGS: YOUR_TARGET_LANGUAGES_HERE ## e.g. "['python', 'dockerfile', 'javascript']" or simply Python
REPO_LANGS: ${{ steps.linguist.outputs.data }}
REPO_LANGS: ${{ steps.enry.outputs.languages }}
11 changes: 9 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def process_comment(comment, ref, sha):
return comment

def process_langs(target_langs, repo_langs):

## Check for valid repo_langs value
if (repo_langs is None):
raise ValueError('Repo languages is type None.')
if not repo_langs:
raise ValueError('Repo languages dictionary is empty.')

# If target languages are provided
if (len(target_langs) != 0):
Expand Down Expand Up @@ -69,8 +75,7 @@ def process_langs(target_langs, repo_langs):
langs_list += i + " "
print('Target languages found: ' + langs_list + '\nLogging data to Beeminder.')
else:
print('Error: Target languages not found in repository language list.')
return
raise ValueError('Target languages not found in repository language list.')


def main():
Expand All @@ -83,6 +88,8 @@ def main():
comment = os.getenv('INPUT_COMMENT')
target_langs = os.getenv('INPUT_TARGET_LANGS')
repo_langs = os.getenv('INPUT_REPO_LANGS')

print(repo_langs)

# Fail if username is not provided
if (username is None or len(username) == 0):
Expand Down

0 comments on commit 603e5ad

Please sign in to comment.