Skip to content

Commit

Permalink
Add publishing docs to Github Pages step into the Github Workflow
Browse files Browse the repository at this point in the history
RELNOTES=N/A
PiperOrigin-RevId: 354378373
  • Loading branch information
danysantiago authored and Dagger Team committed Jan 28, 2021
1 parent 0d9be94 commit 89b334d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 'Publish latest docs'
run: ./util/generate-latest-docs.sh
shell: bash
env:
GH_TOKEN: ${{ github.token }}
- name: 'Publish latest snapshot'
run: ./util/publish-snapshot-on-commit.sh
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public void testActivityInject() throws Exception {
} catch (RuntimeException e) {
// Just skip this test if the root view never becomes active.
// This issue occurs sporadically in emulator tests and causes the test to be flaky.
// It is likely caused by a race between our actiivty and a dialog or lock screen but
// it's difficult to debug this since it only fails in travis builds.
// It is likely caused by a race between our activity and a dialog or lock screen but
// it's difficult to debug this since it only fails in CI builds.
// TODO(b/176111885): Remove this once this bug is fixed.
if (!e.getMessage().startsWith("Waited for the root of the view hierarchy")) {
throw e;
Expand Down
23 changes: 10 additions & 13 deletions util/generate-latest-docs.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# see http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/ for details

set -eux

if [ "$TRAVIS_REPO_SLUG" == "google/dagger" ] && \
[ "$TRAVIS_JDK_VERSION" == "$JDK_FOR_PUBLISHING" ] && \
[ "$TRAVIS_PULL_REQUEST" == "false" ] && \
[ "$TRAVIS_BRANCH" == "master" ]; then
if [ "$GITHUB_REPOSITORY" == "google/dagger" ] && \
[ "$GITHUB_EVENT_NAME" == "push" ] && \
[ "$GITHUB_REF" == "refs/heads/master" ]; then
echo -e "Publishing javadoc...\n"
bazel build //:user-docs.jar
JAVADOC_JAR="$(pwd)/bazel-bin/user-docs.jar"

cd $HOME
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/google/dagger gh-pages > /dev/null
git clone --quiet --branch=gh-pages https://x-access-token:${GH_TOKEN}@github.com/google/dagger gh-pages > /dev/null

cd gh-pages
git config --global user.email "[email protected]"
git config --global user.name "travis-ci"
git config --global user.email "[email protected]"
git config --global user.name "Dagger Team"
git rm -rf api/latest
mkdir -p api
unzip "$JAVADOC_JAR" -d api/latest
Expand All @@ -25,14 +22,14 @@ if [ "$TRAVIS_REPO_SLUG" == "google/dagger" ] && \
# Check if there are any changes before committing, otherwise attempting
# to commit will fail the build (https://stackoverflow.com/a/2659808).
if git diff-index --quiet HEAD --; then
# The exist status is 1, meaing there are changes to commit
git commit -m "Latest javadoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages"
# The exist status is 1, meaning there are changes to commit
git commit -m "Latest javadoc on successful Github build $GITHUB_WORKFLOW/$GITHUB_RUN_ID auto-pushed to gh-pages"
git push -fq origin gh-pages > /dev/null
echo -e "Published Javadoc to gh-pages.\n"
else
# The exist status is 0, meaing there are no changes to commit
# The exist status is 0, meaning there are no changes to commit
echo -e "Skipping publishing docs since no changes were detected."
fi
else
echo -e "Not publishing docs for jdk=${TRAVIS_JDK_VERSION} and branch=${TRAVIS_BRANCH}"
echo -e "Not publishing docs for branch=${$GITHUB_REF}"
fi
4 changes: 2 additions & 2 deletions util/run-local-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -ex

# These jobs should match travis.yml. We can't run this script directly in
# travis since it's too slow for a single job.
# These jobs should match .github/workflows/ci.yml. We can't run this script
# directly in Github since it's too slow for a single job.

# Run local bazel tests
bazel test --test_output=errors //...
Expand Down

0 comments on commit 89b334d

Please sign in to comment.