Skip to content

Commit

Permalink
fix: [#56] Use binary instead of downloading pip packages
Browse files Browse the repository at this point in the history
  • Loading branch information
030 committed Oct 14, 2024
1 parent 6e2a700 commit cf0aef4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 30 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: python
---
name: Python
'on': push
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
MCVS-python-action:
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
#
#
#
#
#
- uses: actions/[email protected]
- uses: 030/mcvs-python-action@1-2-install-python-run-pytest
with:
python-version: 3.9.18
cache: 'pip'
- name: Install PIP packages defined in requirements.txt
run: |
pip install -r requirements.txt
- name: Run tests
run: |
pytest --cov=main test.py --verbose --capture=no --cov-report term-missing
pyinstaller-binary-name: gomod-go-version-updater
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.18
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ The rationale for this action is that
[Dependabot cannot](https://github.com/dependabot/dependabot-core/issues/9057)
update the go version that is defined in a `go.mod` file.

## Development

```zsh
pip install pyinstaller==v6.10.0
pyinstaller --onefile main.py --name gomod-go-version-updater
./dist/gomod-go-version-updater
```

## Usage

1. To use this action, ensure that:
Expand Down
49 changes: 33 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
gomod-go-version-updater-action-log-level:
description: |
Change the default INFO log level to: DEBUG, WARNING, ERROR or CRITICAL.
gomod-go-version-updater-version:
description: |
The gomod-go-version-updater version.
required: true
workflow_file:
default: golang.yml
description: |
Expand All @@ -22,18 +26,12 @@ runs:
- uses: actions/[email protected]
with:
ref: main
# yamllint disable rule:line-length
- name: set branch name
run: |
echo "GOMOD_GO_VERSION_UPDATER_LABEL=gomod-go-version-updater" >> $GITHUB_ENV
echo "GOMOD_GO_VERSION_UPDATER_ACTION_BRANCH=update-go-version-in-go-mod-file" >> $GITHUB_ENV
shell: bash
- uses: actions/[email protected]
with:
python-version: 3.9.18
- name: Install dependencies
run: |
pip install pytest pytest-cov requests
shell: bash
- name: Create label
run: |
gh label create ${GOMOD_GO_VERSION_UPDATER_LABEL} --color "#F50BAB" --description "Pull requests that update Go version in the go.mod file" --force
Expand All @@ -45,14 +43,16 @@ runs:
git fetch -p -P
git checkout -b ${GOMOD_GO_VERSION_UPDATER_ACTION_BRANCH}
python --version
python3 --version
export GOMOD_GO_VERSION_UPDATER_FILE=${GOMOD_GO_VERSION_UPDATER_LABEL}
curl -L https://github.com/030/gomod-go-version-updater-action/releases/download/${{ inputs.gomod-go-version-updater-version }}/${GOMOD_GO_VERSION_UPDATER_FILE} \
-o ${GOMOD_GO_VERSION_UPDATER_FILE}
chmod +x ${GOMOD_GO_VERSION_UPDATER_FILE}
if [ -n "${{ inputs.gomod-go-version-updater-action-log-level }}" ]; then
export GOMOD_GO_VERSION_UPDATER_ACTION_LOGGING_LEVEL=${{ inputs.gomod-go-version-updater-action-log-level }}
echo "GOMOD_GO_VERSION_UPDATER_ACTION_LOGGING_LEVEL: ${GOMOD_GO_VERSION_UPDATER_ACTION_LOGGING_LEVEL}"
fi
export GOMOD_GO_VERSION_UPDATER_ACTION_OUTPUT=$(python ${{ github.action_path }}/main.py 2>&1)
export GOMOD_GO_VERSION_UPDATER_ACTION_OUTPUT=$(./${GOMOD_GO_VERSION_UPDATER_FILE} 2>&1)
echo "GOMOD_GO_VERSION_UPDATER_ACTION_OUTPUT: ${GOMOD_GO_VERSION_UPDATER_ACTION_OUTPUT}"
export GOMOD_GO_VERSION_UPDATER_ACTION_NEW_GOLANG_VERSION_OUTPUT=$(echo ${GOMOD_GO_VERSION_UPDATER_ACTION_OUTPUT} |\
Expand All @@ -63,17 +63,25 @@ runs:
export GOMOD_GO_VERSION_UPDATER_ACTION_MESSAGE="build(deps): ${GOMOD_GO_VERSION_UPDATER_ACTION_NEW_GOLANG_VERSION_OUTPUT}"
echo "GOMOD_GO_VERSION_UPDATER_ACTION_MESSAGE: ${GOMOD_GO_VERSION_UPDATER_ACTION_MESSAGE}"
if [ -n "$(git status --porcelain)" ]; then echo "There are uncommitted changes."; else echo "No changes to commit." && exit 0; fi
if [ -n "$(git status --porcelain)" ]; then
echo "There are uncommitted changes."
else
echo "No changes to commit."
exit 0
fi
echo "git add..."
git add go.mod
echo "git config user..."
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git config user.email \
41898282+github-actions[bot]@users.noreply.github.com
echo "git commit..."
if ! git commit -m "${GOMOD_GO_VERSION_UPDATER_ACTION_MESSAGE}"; then git commit --amend --no-edit; fi
if ! git commit -m "${GOMOD_GO_VERSION_UPDATER_ACTION_MESSAGE}"; then
git commit --amend --no-edit
fi
echo "git push..."
git push origin ${GOMOD_GO_VERSION_UPDATER_ACTION_BRANCH} -f
Expand All @@ -98,23 +106,32 @@ runs:
shell: bash
env:
GH_TOKEN: ${{ github.token }}
# yamllint enable rule:line-length
- uses: actions/[email protected]
with:
go-version-file: 'go.mod'
cache: false
# yamllint disable rule:line-length
- run: |
git config --global url.https://${{ inputs.github-token-for-downloading-private-go-modules }}@github.com/.insteadOf https://github.com/
git config \
--global url.https://${{ inputs.github-token-for-downloading-private-go-modules }}@github.com/.insteadOf https://github.com/
shell: bash
if: ${{ inputs.github-token-for-downloading-private-go-modules != '' }}
# yamllint enable rule:line-length
- name: go mod tidy
run: |
go mod tidy
shell: bash
- name: commit and force push if needed
run: |
if [ -n "$(git status --porcelain)" ]; then echo "There are uncommitted changes."; else echo "No changes to commit." && exit 0; fi
if [ -n "$(git status --porcelain)" ]; then
echo "There are uncommitted changes."
else
echo "No changes to commit."
exit 0
fi
git add .
git add . -- ":!${GOMOD_GO_VERSION_UPDATER_LABEL}"
git commit --amend --no-edit
git push origin ${GOMOD_GO_VERSION_UPDATER_ACTION_BRANCH} -f
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage==7.6.3
pytest-cov==5.0.0
requests==2.32.3
requests==2.32.3

0 comments on commit cf0aef4

Please sign in to comment.