Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#56] Use binary instead of downloading pip packages #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
47 changes: 31 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,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 +39,18 @@ runs:
git fetch -p -P
git checkout -b ${GOMOD_GO_VERSION_UPDATER_ACTION_BRANCH}

python --version
python3 --version
echo "github.ref_name: ${{ github.ref_name }}"

export GOMOD_GO_VERSION_UPDATER_FILE=${GOMOD_GO_VERSION_UPDATER_LABEL}
curl -L https://github.com/030/gomod-go-version-updater-action/releases/download/${{ github.ref_name }}/${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 +61,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 +104,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
Loading