Skip to content
Snippets Groups Projects
Unverified Commit e79c114c authored by Ryan Laurie's avatar Ryan Laurie Committed by GitHub
Browse files

Use correct build dependencies for build-for-release job (#34457)

parent a96e7770
Branches
Tags
No related merge requests found
......@@ -99,8 +99,40 @@ jobs:
&& echo "Commit found in correct release branch" \
|| (echo "Commit not found in correct release branch" && exit 1)
get-build-requirements:
runs-on: ubuntu-22.04
timeout-minutes: 10
outputs:
java_version: ${{ fromJson(steps.dependencies.outputs.result).java_version }}
node_version: ${{ fromJson(steps.dependencies.outputs.result).node_version }}
build_process: ${{ fromJson(steps.dependencies.outputs.result).build_process }}
steps:
- uses: actions/checkout@v3
with:
sparse-checkout: release
- name: Prepare build scripts
run: cd ${{ github.workspace }}/release && yarn && yarn build
- name: Get build dependencies
uses: actions/github-script@v6
id: dependencies
with:
script: | # js
const { getBuildRequirements, getMajorVersion } = require('${{ github.workspace }}/release/dist/index.cjs');
const version = '${{ inputs.version }}';
const requirements = getBuildRequirements(version);
const build_process = getMajorVersion(version) < 46 ? 'legacy' : 'new';
console.log('Build process:', build_process);
return {
java_version: requirements.java,
node_version: requirements.node,
build_process,
};
build-uberjar-for-release:
needs: [check-version, check-commit]
needs: [check-version, check-commit, get-build-requirements]
runs-on: ubuntu-22.04
timeout-minutes: 50
strategy:
......@@ -109,6 +141,24 @@ jobs:
env:
INTERACTIVE: false
steps:
- name: Get correct version number
run: | # bash
if [ '${{matrix.edition}}' == 'ee' ]; then
version='${{ needs.check-version.outputs.ee }}'
else
version='${{ needs.check-version.outputs.oss }}'
fi
echo "VERSION=$version" >> $GITHUB_ENV
- name: Setup Java ${{ needs.get-build-requirements.outputs.java_version }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ needs.get-build-requirements.outputs.java_version }}
- name: Setup Node.js ${{ needs.get-build-requirements.outputs.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ needs.get-build-requirements.outputs.node_version }}.x
- name: Check out the code
uses: actions/checkout@v3
with:
......@@ -119,13 +169,13 @@ jobs:
- name: Prepare back-end environment
uses: ./.github/actions/prepare-backend
- name: Build Metabase ${{ needs.check-version.outputs.ee }}
if: ${{ matrix.edition == 'ee' }}
run: ./bin/build.sh :edition :${{ matrix.edition }} :version ${{ needs.check-version.outputs.ee }}
- name: Build Metabase
if: ${{ needs.get-build-requirements.outputs.build_process != 'legacy' }}
run: ./bin/build.sh :edition :${{ matrix.edition }} :version $VERSION
- name: Build Metabase ${{ needs.check-version.outputs.oss }}
if: ${{ matrix.edition == 'oss' }}
run: ./bin/build.sh :edition :${{ matrix.edition }} :version ${{ needs.check-version.outputs.oss }}
- name: Build Metabase (legacy)
if: ${{ needs.get-build-requirements.outputs.build_process == 'legacy' }}
run: cd ./bin/build-mb && clojure -X build/build! :edition :${{ matrix.edition }} :version $VERSION
- name: Store commit's SHA-1 hash
run: echo ${{ inputs.commit }} > COMMIT-ID
......
......@@ -100,6 +100,29 @@ export const isLatestVersion = (thisVersion: string, allVersions: string[]) => {
return compareVersions(String(coerce(thisVersion.replace(/(v1|v0)\./, ''))), lastVersion) > -1;
};
const versionRequirements: Record<number, { java: number, node: number }> = {
43: { java: 8, node: 14 },
44: { java: 11, node: 14 },
45: { java: 11, node: 14 },
46: { java: 11, node: 16 },
47: { java: 11, node: 18 },
};
export const getBuildRequirements = (version: string) => {
if (!isValidVersionString(version)) {
throw new Error(`Invalid version string: ${version}`);
}
const majorVersion = Number(getMajorVersion(version));
if (majorVersion in versionRequirements) {
return versionRequirements[majorVersion];
}
const lastKey = Object.keys(versionRequirements)[Object.keys(versionRequirements).length - 1];
console.warn(`No build requirements found for version ${version}, using latest: v${lastKey}`);
return versionRequirements[Number(lastKey)];
}
export const getNextVersions = (versionString: string): string[] => {
if (!isValidVersionString(versionString)) {
throw new Error(`Invalid version string: ${versionString}`);
......
......@@ -7,6 +7,7 @@ import {
getVersionType,
getReleaseBranch,
isLatestVersion,
getBuildRequirements,
getNextVersions,
} from "./version-helpers";
......@@ -279,6 +280,48 @@ describe("version-helpers", () => {
});
});
describe("getBuildRequirements", () => {
it("should return the correct build requirements for provided ee version", () => {
expect(getBuildRequirements("v1.47.2.1")).toEqual({
node: 18,
java: 11,
});
});
it("should return the correct build requirements for provided oss version", () => {
expect(getBuildRequirements("v0.47.2.1")).toEqual({
node: 18,
java: 11,
});
});
it("should return the correct build requirements for a major version release", () => {
expect(getBuildRequirements("v0.47.0")).toEqual({
node: 18,
java: 11,
});
});
it("should return the correct build requirements for an RC release", () => {
expect(getBuildRequirements("v0.47.0-RC7")).toEqual({
node: 18,
java: 11,
});
});
it("should throw an error for invalid versions", () => {
expect(() => getBuildRequirements("foo")).toThrow();
expect(() => getBuildRequirements("v2.47.6")).toThrow();
});
it('should use the latest build requirements for a version that has not been released', () => {
expect(getBuildRequirements("v0.99.0")).toEqual({
node: 18,
java: 11,
});
});
});
describe('getNextVersions', () => {
it('should get next versions for a major release', () => {
const testCases: [string, string[]][] = [
......@@ -342,5 +385,5 @@ describe("version-helpers", () => {
expect(() => getNextVersions('v2.75')).toThrow();
expect(() => getNextVersions('v0.75-RC2')).toThrow();
});
})
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment