Skip to content

Move CI from TravisCI to GitHub Actions #339

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

Merged
Merged
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
31 changes: 31 additions & 0 deletions .github/workflows/maven-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will put the project in our staging repo
name: Releasing Project to maven

on:
release:
types: [ published ]

jobs:
build:
if: endsWith(github.ref, "-lib")
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
Comment on lines +11 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these environment variables used for anything btw?

Suggested change
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1

Copy link
Contributor Author

@johnttompkins johnttompkins Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah if you dont have these set the unit tests fail 🤷🏻 something with initializing aws clients in unit tests. maybe at a later date we can look into why these are necessary are try to remove

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java & publishing credentials
uses: actions/setup-java@v1
with:
java-version: 8
server-id: sonatype-nexus-staging # Value of the distributionManagement/repository/id field of the pom.xml
server-username: SONATYPE_USERNAME # env variable for username in deploy
server-password: SONATYPE_PASSWORD # env variable for token in deploy
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Deploy to sonatype staging repo
run: mvn deploy -Ppublishing
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Comment on lines +15 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confused what's going on with secrets/env variables here

looks similar to actions/setup-java README but don't understand why env variables are set in the step after they're used 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's to limit the scope of when these secrets are on the build machine. the setup-java step simply creates a configuration file which points to environment variables then the deploy step sets these when the configuration file is actually used (during the mvn deploy command)

49 changes: 49 additions & 0 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will install dependencies, run tests for both plugin and library components
name: CloudFormation CLI Java Plugin Pull Request CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
strategy:
matrix:
python: [3.6, 3.7, 3.8]
Copy link
Contributor

@PatMyron PatMyron Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linking aws-cloudformation/cloudformation-cli-python-plugin#139 again just so we don't forget later
we should just sweep all these repos when we get Python 3.9 working:

Suggested change
python: [3.6, 3.7, 3.8]
python: [3.6, 3.7, 3.8, 3.9]

java: [8, 11]
runs-on: ubuntu-latest
Copy link
Contributor

@PatMyron PatMyron Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well test on macos-latest and windows-latest here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added. i think it might also be useful to test compatibility with published libraries and plugins i.e. since we are managing two different packages of software, we should test the library against the published plugin and vice versa to ensure backwards compatibility. These things get missed since we test the built library in a given PR with the built plugin in the given PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing some macos failures trying to build the java library. going to leave out the multiple OS testing for now since this was just supposed to be a migration and create a followup so we can do this in a more targeted way where we aren't just running 18 jobs for one pr. ideally we'd only need to test compatibility of the plugin with the given OS

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Install python dependencies
run: |
pip install --upgrade 'attrs==19.2.0' wheel -r https://raw.githubusercontent.com/aws-cloudformation/cloudformation-cli/master/requirements.txt
- name: Install cloudformation-cli-java-plugin
run: |
pip install .
- name: Run pre-commit, twine checks for cloudformation-cli-java-plugin
run: |
pre-commit run --all-files
python setup.py sdist bdist_wheel
twine check ./dist/*
- name: Verify java package
run:
mvn verify
- name: Integration standard e2e
run:
./e2e_test.sh 1
- name: Integration guided e2e
run:
./e2e_test.sh 2
27 changes: 27 additions & 0 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will release project to PyPI
name: CloudFormation CLI Java Plugin Release

on:
release:
types: [ published ]

jobs:
build:
if: endsWith(github.ref, "-plugin")
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install --upgrade wheel twine
- name: Package project
run: |
python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI (If triggered from release)
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_KEY_CLOUDFORMATION_CLI_JAVA_PLUGIN }}
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions e2e_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
DIR=$(mktemp -d)
cd "$DIR"
ls -la

printf "\n\n$1" | cfn init -t AWS::Foo::Bar -a RESOURCE -vv
ls -la
mvn verify
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@
<goals>
<goal>sign</goal>
</goals>
<configuration>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add this to pick up the passphrase for the gpg key that is set in the setup java step

<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
Expand Down