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

Add CI checks for un-committed code generation #389

Open
wants to merge 11 commits into
base: master
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
11 changes: 11 additions & 0 deletions .github/actions/check-generation/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Check generation is committed"
description: "Ensure that all code generation is present in the commits"
runs:
using: composite
steps:
- shell: bash
run: |
git add .
git update-index --refresh
git diff-index --quiet --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** || \
(git --no-pager diff HEAD -- ; echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" ; exit 1)
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
yum -y update
yum -y install centos-release-scl-rh epel-release
yum -y install java-11-openjdk-devel devtoolset-7
yum -y install java-11-openjdk-devel devtoolset-7 git
echo Downloading Maven
curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz
tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/
Expand All @@ -41,6 +41,8 @@ jobs:
- name: Run lint checks
run: |
mvn compiler:compile -Pdev,jdk11 -B -U -e
- name: Check for un-committed generation
uses: ./.github/actions/check-generation
check-format:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -148,6 +150,8 @@ jobs:
echo Executing Maven $MAVEN_PHASE
mvn clean $MAVEN_PHASE -B -U -e -Djavacpp.platform=linux-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -pl $NATIVE_BUILD_PROJECTS -am -DstagingRepositoryId=${{ needs.prepare.outputs.stagingRepositoryId }} "-Dnative.build.flags=$BAZEL_CACHE"
df -h
- name: Check for un-committed generation
uses: ./.github/actions/check-generation
macosx-x86_64:
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build')
runs-on: macos-latest
Expand Down Expand Up @@ -184,6 +188,8 @@ jobs:
echo Executing Maven $MAVEN_PHASE
mvn clean $MAVEN_PHASE -B -U -e -Djavacpp.platform=macosx-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -pl $NATIVE_BUILD_PROJECTS -am -DstagingRepositoryId=${{ needs.prepare.outputs.stagingRepositoryId }} "-Dnative.build.flags=$BAZEL_CACHE"
df -h
- name: Check for un-committed generation
uses: ./.github/actions/check-generation
windows-x86_64:
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build')
runs-on: windows-latest
Expand Down Expand Up @@ -261,6 +267,8 @@ jobs:
if ERRORLEVEL 1 exit /b
df -h
wmic pagefile list /format:list
- name: Check for un-committed generation
uses: ./.github/actions/check-generation
deploy:
if: github.event_name == 'push' && contains(github.ref, 'master')
needs: [linux-x86_64, macosx-x86_64, windows-x86_64]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,70 +341,70 @@
* }</pre>
*/
public final class Ops {
public final NnOps nn;

public final SummaryOps summary;

public final ImageOps image;
public final AudioOps audio;

public final RaggedOps ragged;
public final BitwiseOps bitwise;

public final DataOps data;

public final ShapeOps shape;
public final DtypesOps dtypes;

public final ImageOps image;

public final IoOps io;

public final DtypesOps dtypes;
public final LinalgOps linalg;

public final XlaOps xla;
public final MathOps math;

public final LinalgOps linalg;
public final NnOps nn;

public final RandomOps random;
public final QuantizationOps quantization;

public final StringsOps strings;
public final RaggedOps ragged;

public final SparseOps sparse;
public final RandomOps random;

public final BitwiseOps bitwise;
public final ShapeOps shape;

public final TpuOps tpu;
public final SignalOps signal;

public final MathOps math;
public final SparseOps sparse;

public final AudioOps audio;
public final StringsOps strings;

public final SignalOps signal;
public final SummaryOps summary;

public final TpuOps tpu;

public final TrainOps train;

public final QuantizationOps quantization;
public final XlaOps xla;

private final Scope scope;

private Ops(Scope scope) {
this.scope = scope;
nn = new NnOps(this);
summary = new SummaryOps(this);
image = new ImageOps(this);
ragged = new RaggedOps(this);
audio = new AudioOps(this);
bitwise = new BitwiseOps(this);
data = new DataOps(this);
shape = new ShapeOps(this);
io = new IoOps(this);
dtypes = new DtypesOps(this);
xla = new XlaOps(this);
image = new ImageOps(this);
io = new IoOps(this);
linalg = new LinalgOps(this);
math = new MathOps(this);
nn = new NnOps(this);
quantization = new QuantizationOps(this);
ragged = new RaggedOps(this);
random = new RandomOps(this);
strings = new StringsOps(this);
shape = new ShapeOps(this);
signal = new SignalOps(this);
sparse = new SparseOps(this);
bitwise = new BitwiseOps(this);
strings = new StringsOps(this);
summary = new SummaryOps(this);
tpu = new TpuOps(this);
math = new MathOps(this);
audio = new AudioOps(this);
signal = new SignalOps(this);
train = new TrainOps(this);
quantization = new QuantizationOps(this);
xla = new XlaOps(this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,19 +698,21 @@ private static void addGroupFields(
MethodSpec.Builder ctorBuilder,
List<OpsSpec> groups,
boolean isTopClass) {
groups.forEach(
group -> {
classBuilder.addField(
FieldSpec.builder(group.className, group.fieldName)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.build());
ctorBuilder
.addStatement(
"$L = new $T(" + (isTopClass ? "this" : "ops") + ")",
group.fieldName,
group.className)
.build();
});
groups.stream()
.sorted(Comparator.comparing(g -> g.fieldName))
.forEach(
group -> {
classBuilder.addField(
FieldSpec.builder(group.className, group.fieldName)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.build());
ctorBuilder
.addStatement(
"$L = new $T(" + (isTopClass ? "this" : "ops") + ")",
group.fieldName,
group.className)
.build();
});
}

private static AnnotationMirror getAnnotationMirror(Element element, Name annotationName) {
Expand Down